NSPasteboardItem
An item on a pasteboard.
Declaration
class NSPasteboardItemOverview
There are three main uses for an NSPasteboardItem object:
Providing data on the pasteboard.
You can create one or more pasteboard items, set data or data providers for types, and write them to the pasteboard.
Customizing data already on the pasteboard.
As a delegate or subclass, you can retrieve the pasteboard items currently on the pasteboard, read the existing types and data, and set new data and data providers for types as necessary.
Retrieving data from the pasteboard.
You can retrieve pasteboard items from the pasteboard and then read the data for types you’re interested in.
A pasteboard item can be associated with a single pasteboard. When you create an item, you can write it to any pasteboard. When you pass an item to a pasteboard in writeObjects(_:), that item becomes bound to the pasteboard it writes to. When you retrieve items from a pasteboard using pasteboardItems or readObjects(forClasses:options:), the returned items are associated with the messaged pasteboard. Passing an item that is already associated with a pasteboard into writeObjects(_:) causes an exception.
Use pasteboard items during a single pasteboard interaction, rather than retaining and reusing them. A pasteboard item is only valid until the owner of the pasteboard changes.
Topics
Getting types
Setting the data provider
Setting values
Getting values
Detecting patterns and metadata in pasteboard items
detectedPatterns(for:)detectedValues(for:)NSPasteboardItem.DetectedValuesdetectedMetadata(for:)NSPasteboardItem.DetectedMetadata