declareTypes(_:owner:)
Prepares the receiver for a change in its contents by declaring the new types of data it will contain and a new owner.
Declaration
func declareTypes(_ newTypes: [NSPasteboard.PasteboardType], owner newOwner: Any?) -> IntParameters
- newTypes:
An array of
NSStringobjects that specify the types of data that may be added to the new pasteboard. The types should be ordered according to the preference of the source application, with the most preferred type coming first (typically, the richest representation). - newOwner:
The object responsible for writing data to the pasteboard, or
nilif you provide data for all types immediately. If you specify anewOwnerobject, it must support all of the types declared in thenewTypesparameter and must remain alive for as long as the data is promised on the pasteboard.
Return Value
The receiver’s new change count.
Discussion
This method is the equivalent of invoking clearContents(), implicitly writing the first pasteboard item, and then calling addTypes(_:owner:) to promise types for the first pasteboard item.
Special Considerations
In general, you should not use this method with writeObjects(_:), since writeObjects(_:) will always write additional items to the pasteboard, and will not affect items already on the pasteboard, including the item implicitly created by this method.