| Conforms to | |
| Availability | Available in Mac OS X v10.6 and later. |
| Declared in | NSPasteboard.h |
| Companion guides | |
| Related sample code |
The NSPasteboardReading protocol specifies the interface for initializing an object from a pasteboard. The Cocoa framework classes NSString, NSAttributedString, NSURL, NSColor, NSSound, NSImage, and NSPasteboardItem implement this protocol. You can make your custom class conform to this protocol so that you can read instances from a pasteboard using the readObjectsForClasses:options: method of NSPasteboard.
+ readableTypesForPasteboard: required method
+ readingOptionsForType:pasteboard: required method
– initWithPasteboardPropertyList:ofType: required method
Returns an array of UTI strings of data types the receiver can read from the pasteboard and be initialized from. (required)
+ (NSArray *)readableTypesForPasteboard:(NSPasteboard *)pasteboard
A pasteboard.
You can use the pasteboard argument to provide different types based on the pasteboard name, should you need to do so.
An array of UTI strings of data types instances of the receiver can read from the pasteboard and be initialized from.
By default, the data for a type is provided to initWithPasteboardPropertyList:ofType: as an instance of NSData. If you implement readingOptionsForType:pasteboard: and specify a different option, the NSData object for a type can be converted to an NSString object or any other property list object.
Do not perform other pasteboard operations in the method implementation.
NSPasteboard.hReturns options for reading data of a specified type from a given pasteboard. (required)
+ (NSPasteboardReadingOptions)readingOptionsForType:(NSString *)type pasteboard:(NSPasteboard *)pasteboard
A UTI supported by instances of the receiver for reading (one of the types returned by readableTypesForPasteboard:).
A pasteboard.
You can use the pasteboard argument to provide return different based on the pasteboard name, should you need to do so.
Options for reading data of type from pasteboard. For a list of valid values, see “Pasteboard Reading Options.”
Do not perform other pasteboard operations in the method implementation.
NSPasteboard.hInitializes an instance with a property list object and a type string. (required)
- (id)initWithPasteboardPropertyList:(id)propertyList ofType:(NSString *)type
A property list containing data to initialize the receiver.
By default, the property list object is an instance of NSData. If you implement readingOptionsForType:pasteboard: and specify an option other than NSPasteboardReadingAsData, the propertyList may be any other property list object.
A UTI supported by the receiver for reading (one of the types returned by readableTypesForPasteboard:).
An object initialized using the data in propertyList.
This method is considered optional because, if readableTypesForPasteboard: returns just a single type, and that type uses the NSPasteboardReadingAsKeyedArchive reading option, then instances are initialized using initWithCoder: instead of this method.
NSPasteboard.hOptions to specify how data on the pasteboard should be interpreted to initialize an object in initWithPasteboardPropertyList:ofType:.
enum {
NSPasteboardReadingAsData = 0,
NSPasteboardReadingAsString = 1 << 0,
NSPasteboardReadingAsPropertyList = 1 << 1,
NSPasteboardReadingAsKeyedArchive = 1 << 2
};
NSPasteboardReadingAsDataReads data from the pasteboard as-is and returns it as an NSData object.
This is the default value.
Available in Mac OS X v10.6 and later.
Declared in NSPasteboard.h.
NSPasteboardReadingAsStringReads data from the pasteboard and converts it to an NSString object.
Available in Mac OS X v10.6 and later.
Declared in NSPasteboard.h.
NSPasteboardReadingAsPropertyListReads data from the pasteboard and un-serializes it as a property list.
Available in Mac OS X v10.6 and later.
Declared in NSPasteboard.h.
NSPasteboardReadingAsKeyedArchiveReads data from the pasteboard and uses initWithCoder: to initialize the object.
Available in Mac OS X v10.6 and later.
Declared in NSPasteboard.h.
You can specify only one option from this list. If you do not specify an option, the default NSPasteboardReadingAsData is used.
A type to specify how data on the pasteboard should be interpreted to initialize an object in initWithPasteboardPropertyList:ofType:.
typedef NSUInteger NSPasteboardReadingOptions;
For valid values, see “Pasteboard Reading Options.”
NSPasteboard.hLast updated: 2009-01-21