Instance Method


Prepares the receiver for a change in its contents by declaring the new types of data it will contain and a new owner.


- (NSInteger)declareTypes:(NSArray<NSPasteboardType> *)newTypes owner:(id)newOwner;



An array of NSString objects 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).


The object responsible for writing data to the pasteboard, or nil if you provide data for all types immediately. If you specify a newOwner object, it must support all of the types declared in the newTypes parameter and must remain alive for as long as the data is promised on the pasteboard.

Return Value

The receiver's new change count.


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.

See Also

Writing Data (macOS 10.5 and Earlier)

- addTypes:owner:

Adds promises for the specified types to the first pasteboard item.

- writeFileContents:

Writes the contents of the specified file to the pasteboard.

- writeFileWrapper:

Writes the serialized contents of the specified file wrapper to the pasteboard.