Instance Method

setValue(_:forPasteboardType:)

Puts an object in the pasteboard for the specified representation type.

Declaration

func setValue(_ value: Any, forPasteboardType pasteboardType: String)

Parameters

value

The object to be written to the pasteboard.

pasteboardType

A string identifying the representation type of the pasteboard item. If the type is a UTI, it must be compatible with the class of value; otherwise, nothing is written to the pasteboard.

Discussion

Use this method to put an object—such as an NSString, NSArray, NSDictionary, NSDate, NSNumber, UIImage, or NSURL object—on the pasteboard. (For images, you can also use the image or images properties; for all other data, such as raw binary data, use the setData(_:forPasteboardType:) method.) This method writes the object as the first item in the pasteboard. Calling this method replaces any items currently in the pasteboard.

See Also

Getting and Setting Single Pasteboard Items

func data(forPasteboardType: String) -> Data?

Returns the data in the pasteboard for the given representation type.

func value(forPasteboardType: String) -> Any?

Returns an object in the pasteboard for the given representation type.

func setData(Data, forPasteboardType: String)

Puts data in the pasteboard for the specified representation type.