< Previous PageNext Page > Hide TOC

Data Types

Data can be placed in the pasteboard server in more than one representation. For example, an image might be provided both in Tag Image File Format (TIFF) and as encapsulated PostScript code (EPS). Multiple representations give pasting applications the option of choosing which data type to use. In general, an application taking data from the pasteboard should choose the richest representation it can handle—rich text over plain ASCII, for example. An application putting data in the pasteboard should promise to supply it in as many data types as possible, so that as many different applications as possible can use it.

Filtering services (see “Filter Services”) transform the data from one representation to another. Typically, these services are not invoked until data are read from a pasteboard.

Data types are identified by string objects containing the full type name. These global variables identify the string objects for the standard pasteboard types:

NSColorPboardTypeNSColor data
NSInkTextPboardTypeInk text data. For information on ink text objects, see Using Ink Services in Your Application. Available in Mac OS X v10.4 and later..
NSFileContentsPboardTypeA representation of a file’s contents
NSFilesPromisePboardTypePromised files
NSCreateFileContentsPboardTypeReturns a pasteboard type based on the passed file type.
NSCreateFilenamePboardTypeReturns a pasteboard type based on the passed file type.
NSFilenamesPboardTypeArray of NSString objects designating one or more filenames
NSFindPanelSearchOptionsPboardTypeType for NSFindPanel metadata property list. Used with the NSPasteBoard method propertyListForType:.
NSFontPboardTypeFont and character information
NSHTMLPboardTypeHTML (which an NSTextView object can read from, but not write to)
NSPDFPboardTypePDF data
NSPICTPboardTypeQuickDraw picture data
NSPostScriptPboardTypeEncapsulated PostScript (EPS) code
NSRTFPboardTypeRich Text Format (RTF)
NSRTFDPboardTypeRTFD formatted file contents
NSRulerPboardTypeParagraph formatting information
NSSoundPboardTypeNSSound data
NSStringPboardTypeNSString data
NSTabularTextPboardTypeAn NSString object containing tab-separated fields of text
NSTIFFPboardTypeTag Image File Format (TIFF)
NSURLPboardTypeNSURL data for one file or resource
NSVCardPboardTypeVCard data
WebArchivePboardTypeThe pasteboard type constant used when adding or accessing a WebArchive on the pasteboard.

Typically, data is written to the pasteboard using setData:forType: and read using dataForType:. Some of these types can only be written with certain methods. For instance, NSFilenamesPboardType’s form is an array of NSString objects and requires special handling. Use these methods to write these types:

Type

Writing Method

Reading Method

NSColorPboardType

NSColor class methods

NSColor class methods

NSFileContentsPboardType

writeFileContents:

readFileContentsType:toFile:

NSFilenamesPboardType

setPropertyList:forType:

propertyListForType:

NSStringPboardType

setString:forType:

stringForType:

NSURLPboardType

writeToPasteboard: (NSURL)

URLFromPasteboard: (NSURL)

NSFontPboardType

See “Writing Font Data”

See “Reading Font Data”

Types other than those listed above can also be used. For example, your application may keep data in a private format that is richer than any of the existing types. That format can also be used as a pasteboard type.



< Previous PageNext Page > Hide TOC


© 2007 Apple Inc. All Rights Reserved. (Last updated: 2007-07-13)


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.