An item provider for conveying data or a file between processes during drag and drop or copy/paste activities, or from a host app to an app extension.
- iOS 8.0+
- macOS 10.10+
- Mac Catalyst 13.0+
- tvOS 9.0+
- watchOS 2.0+
Starting in iOS 11, item providers play a central role in drag and drop, and in copy/paste. They continue to play a role with app extensions.
All completion blocks used in the
NSItem class are called by the system on an internal queue. When using an item provider with drag and drop, ensure that user-interface updates take place on the main queue as follows:
App Extension Support
An app extension typically encounters item providers when examining the
attachments property of an
NSExtension object. During that examination, the extension can use the
has method to look for data that it recognizes. Item providers use Uniform Type Identifier (UTI) values to identify the data they contain. After finding a type of data that your extension can use, it calls the
load method to load the actual data, which is delivered to the provided completion handler.
You can create item providers to vend data to another process. An extension that modifies an original data item can create a new NSItemProvider object to send back to the host app. When creating data items, you specify your data object and the type of that object. You can optionally use the
preview property to generate a preview image for your data.
A single item provider may use custom blocks to provide its data in many different formats. When configuring an item provider, use the
register method to register your blocks and the formats each one supports. When a client requests data in a particular format, the item provider executes the corresponding block, which is then responsible for coercing the data to the appropriate type and returning it to the client.