Instance Method


Loads the item’s data and coerces it (as needed) to the specified type.


func loadItem(forTypeIdentifier typeIdentifier: String, options: [AnyHashable : Any]? = nil, completionHandler: NSItemProvider.CompletionHandler? = nil)



A string that represents the desired UTI.


A dictionary of keys and values that provide information about the item, such as the size of an image. (See NSItemProviderPreferredImageSizeKey for a key you can use.)


A completion handler block to execute with the results. For information about the format of this block, see NSItemProvider.CompletionHandler.


Call this method when you want to retrieve the item provider’s data. If the item provider object is able to provide data in the requested type, it does so and asynchronously executes your completionHandler block with the results. The block may be executed on a background thread.

The type information for the first parameter of your completionHandler block should be set to the class of the expected type. For example, when requesting text data, you might set the type of the first parameter to NSString or NSAttributedString. An item provider can perform simple type conversions of the data to the class you specify, such as from NSURL to NSData or FileWrapper, or from NSData to UIImage (in iOS) or NSImage (in macOS). If the data could not be retrieved or coerced to the specified class, an error is passed to the completion block’s.

See Also

Getting the Item’s Data

func canLoadObject(ofClass: NSItemProviderReading.Type) -> Bool

Returns a Boolean value indicating whether an item provider can load objects of a given class.

func hasItemConformingToTypeIdentifier(String) -> Bool

A convenience method equivalent to the hasRepresentationConforming(toTypeIdentifier:fileOptions:) method, but with the fileOptions parameter set to a value of 0.

func loadDataRepresentation(forTypeIdentifier: String, completionHandler: (Data?, Error?) -> Void) -> Progress

Asynchronously copies the provided, typed data into a Data object, returning a Progress object.

func loadFileRepresentation(forTypeIdentifier: String, completionHandler: (URL?, Error?) -> Void) -> Progress

Asynchronously writes a copy of the provided, typed data to a temporary file, returning a Progress object.

func loadInPlaceFileRepresentation(forTypeIdentifier: String, completionHandler: (URL?, Bool, Error?) -> Void) -> Progress

Asynchronously opens a file in place, if doing so is possible, returning a Progress object.

func loadObject(ofClass: NSItemProviderReading.Type, completionHandler: (NSItemProviderReading?, Error?) -> Void) -> Progress

Asynchronously loads an object of a specified class to an item provider, returning a Progress object.

func hasRepresentationConforming(toTypeIdentifier: String, fileOptions: NSItemProviderFileOptions = []) -> Bool

Returns a Boolean value indicating whether an item provider contains a data representation conforming to a specified uniform type identifier (UTI) and to specified open-in-place behavior.

func registeredTypeIdentifiers(fileOptions: NSItemProviderFileOptions = []) -> [String]

Returns an array with a subset of type identifiers for the item provider, according to the specified file options, listed in the same order in which they were registered.