registerItem(forTypeIdentifier:loadHandler:)
Lazily registers an item, according to the item provider type coercion policy.
Declaration
func registerItem(forTypeIdentifier typeIdentifier: String, loadHandler: @escaping NSItemProvider.LoadHandler)Parameters
- typeIdentifier:
A string that represents the desired UTI.
- loadHandler:
A block capable of returning the data item as the specified type. For information about implementing this block, see Loadhandler.
Discussion
Use this method to register blocks that can take the item provider’s file or data object and convert it to a specific data format. Your loadHandler block is executed when a client passes the same typeIdentifier string to the loadItem(forTypeIdentifier:options:completionHandler:) method. In the implementation of your block, coerce the data to the specified type and call the provided completion handler. You must call the completion handler, either with the requested data or with an error.
Item providers know how to coerce known types of objects, such as images or strings. Use this method to register blocks to coerce your custom data types.