Instance Method

loadItemForTypeIdentifier:options:completionHandler:

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

Declaration

- (void)loadItemForTypeIdentifier:(NSString *)typeIdentifier options:(NSDictionary *)options completionHandler:(NSItemProviderCompletionHandler)completionHandler;

Parameters

typeIdentifier

A string that represents the desired UTI.

options

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.)

completionHandler

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

Discussion

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 NSFileWrapper, 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

- canLoadObjectOfClass:

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

- hasItemConformingToTypeIdentifier:

A convenience method equivalent to the hasRepresentationConformingToTypeIdentifier:fileOptions: method, but with the fileOptions parameter set to a value of 0.

- loadDataRepresentationForTypeIdentifier:completionHandler:

Asynchronously copies the provided, typed data into an NSData object, returning an NSProgress object.

- loadFileRepresentationForTypeIdentifier:completionHandler:

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

- loadInPlaceFileRepresentationForTypeIdentifier:completionHandler:

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

- loadObjectOfClass:completionHandler:

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

- hasRepresentationConformingToTypeIdentifier:fileOptions:

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.

- registeredTypeIdentifiersWithFileOptions:

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.