Setting ""
will return nil
for all intended purposes. However, it will leave the cardboard in a slightly different condition, as before the insertion operation.
Swift
let pb = self.pasteBoard() pb.setValue("", forPasteboardType: UIPasteboardNameGeneral)
... is not equivalent to UIPasteboard.removePasteboardWithName()
. If restoring the state of a UIPasteboard
is a concern (1), you can use the following block:
Swift
let pb = self.pasteBoard() let items:NSMutableArray = NSMutableArray(array: pb.items) for object in pb.items { if let aDictionary = object as? NSDictionary { items.removeObject(aDictionary) } } pb.items = items as [AnyObject]
(1) State recovery.
source share