Mac Developer Library

Developer

NSPasteboardItem Class Reference

Options
Deployment Target:

On This Page
Language:

NSPasteboardItem

NSPasteboardItem is a generic class to represent an item on a pasteboard. More...

Inheritance


Import Statement


import AppKit @import AppKit;

Availability


Available in OS X v10.6 and later.
  • types types Property

    An array of UTI strings of the data types supported by the receiver. (read-only)

    Declaration

    Swift

    var types: [AnyObject]! { get }

    Objective-C

    @property(readonly, copy) NSArray *types

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.6 and later.

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

    Declaration

    Swift

    func availableTypeFromArray(_ types: [AnyObject]) -> String?

    Objective-C

    - (NSString *)availableTypeFromArray:(NSArray *)types

    Parameters

    types

    An array of strings representing UTIs, arranged in order of preference (most preferred as the 0th element in the array).

    Return Value

    The first (according to the sender's ordering of types) type in types contained in the pasteboard item, or nil if the receiver does not contain any types given in types.

    Discussion

    The method checks for UTI conformance of the requested types, preferring an exact match to conformance.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.6 and later.

  • Sets the data provider for the specified types.

    Declaration

    Swift

    func setDataProvider(_ dataProvider: NSPasteboardItemDataProvider!, forTypes types: [AnyObject]) -> Bool

    Objective-C

    - (BOOL)setDataProvider:(id<NSPasteboardItemDataProvider>)dataProvider forTypes:(NSArray *)types

    Parameters

    dataProvider

    A pasteboard data provider.

    types

    An array of strings indicating the UTIs for the data representations dataProvider may provide.

    Return Value

    YEStrue if the data provider was set successfully, otherwise NOfalse.

    Discussion

    This method registers the data provider to be messaged to provide the data for any of the specified types when requested.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.6 and later.

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

    Declaration

    Swift

    func setData(_ data: NSData!, forType type: String) -> Bool

    Objective-C

    - (BOOL)setData:(NSData *)data forType:(NSString *)type

    Parameters

    data

    An NSData object containing the value for the representation specified by type.

    type

    A UTI type string.

    Return Value

    YEStrue if the value was set successfully, otherwise NOfalse.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.6 and later.

  • Sets the value for a specified type as a string.

    Declaration

    Swift

    func setString(_ string: String!, forType type: String) -> Bool

    Objective-C

    - (BOOL)setString:(NSString *)string forType:(NSString *)type

    Parameters

    string

    A string for the representation specified by type.

    type

    A UTI type string.

    Return Value

    YEStrue if the value was set successfully, otherwise NOfalse.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.6 and later.

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

    Declaration

    Swift

    func setPropertyList(_ propertyList: AnyObject!, forType type: String) -> Bool

    Objective-C

    - (BOOL)setPropertyList:(id)propertyList forType:(NSString *)type

    Parameters

    propertyList

    A property list object containing the value for the representation specified by type.

    For about property lists, see Property List Programming Guide.

    type

    A UTI type string.

    Return Value

    YEStrue if the value was set successfully, otherwise NOfalse.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.6 and later.

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

    Declaration

    Swift

    func dataForType(_ type: String) -> NSData?

    Objective-C

    - (NSData *)dataForType:(NSString *)type

    Parameters

    type

    A UTI type string.

    Return Value

    The value for the specified type as an NSData object.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.6 and later.

  • Returns the value for the specified type as a string.

    Declaration

    Swift

    func stringForType(_ type: String) -> String?

    Objective-C

    - (NSString *)stringForType:(NSString *)type

    Parameters

    type

    A UTI type string.

    Return Value

    The value for the specified type as a string.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.6 and later.

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

    Declaration

    Swift

    func propertyListForType(_ type: String) -> AnyObject?

    Objective-C

    - (id)propertyListForType:(NSString *)type

    Parameters

    type

    A UTI type string.

    Return Value

    The value for the specified type as a property list.

    Discussion

    For more about property lists, see Property List Programming Guide.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.6 and later.