Instance Method

setData(_:forPasteboardType:)

Puts data in the pasteboard for the specified representation type.

Declaration

func setData(_ data: Data, forPasteboardType pasteboardType: String)

Parameters

data

The data object to be written to the pasteboard.

pasteboardType

A string identifying the representation type of the pasteboard item. This is typically a UTI.

Discussion

Use this method to put raw data on the pasteboard. For example, you could archive a graph of model objects and pass the resulting NSData object to a related app via a pasteboard using a custom pasteboard type. (To put objects—such as NSString, NSArray, NSDictionary, NSDate, NSNumber, UIImage, or NSURL objects—on the pasteboard, use the setValue(_:forPasteboardType:) method.) This method writes data for 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 setValue(Any, forPasteboardType: String)

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