Class

NSPasteboardItem

An item on a pasteboard.

Declaration

@interface NSPasteboardItem : NSObject

Overview

There are three main uses for an NSPasteboardItem object:

  1. Providing data on the pasteboard.

    You can create one or more pasteboard items, set data or data providers for types, and write to them pasteboard.

  2. 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 needed.

  3. Retrieving data from the pasteboard.

    You can retrieve pasteboard items from the pasteboard 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, it can be written to any pasteboard. When you pass an item to a pasteboard in writeObjects:, that item becomes bound to the pasteboard it was written to. When you retrieve items from a pasteboard using pasteboardItems or readObjectsForClasses: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 to be raised.

Pasteboard items are intended to be used during a single pasteboard interaction, not held onto and used repeatedly. A pasteboard item is only valid until the owner of the pasteboard changes.

Topics

Getting Types

types

An array of UTI strings of the data types supported by the receiver.

- availableTypeFromArray:

Returns from a given array of types the first type contained in the pasteboard item, according to the ordering of types.

Setting the Data Provider

- setDataProvider:forTypes:

Sets the data provider for the specified types.

Setting Values

- setData:forType:

Sets the value for a specified type as an NSData object.

- setString:forType:

Sets the value for a specified type as a string.

- setPropertyList:forType:

Sets the value for a specified type as a property list.

Getting Values

- dataForType:

Returns the value for the specified type as an NSData object.

- stringForType:

Returns the value for the specified type as a string.

- propertyListForType:

Returns the value for the specified type as a property list.

Relationships

Inherits From

See Also

Pasteboard

NSPasteboard

An object that transfers data to and from the pasteboard server.

NSPasteboardReading

A set of methods that defines the interface for initializing an object from a pasteboard.

NSPasteboardWriting

A set of methods that defines the interface for retrieving a representation of an object that can be written to a pasteboard.

NSPasteboardItemDataProvider

A set of methods implemented by the data provider of a pasteboard item to provide the data for a particular UTI type.