<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.10.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSItemProvider",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSItemProvider"
  },
  "title" : "NSItemProvider"
}
-->

# NSItemProvider

An item provider for conveying data or a file between processes during drag-and-drop or copy-and-paste activities, or from a host app to an app extension.

```
class NSItemProvider
```

## Overview

Starting in iOS 11, item providers play a central role in drag and drop, and in copy and paste. They continue to play a role with app extensions.

The system uses an internal queue when calling the completion blocks for the `NSItemProvider` class. When using an item provider with drag and drop, ensure that UI updates take place on the main queue as follows:

```swift
DispatchQueue.main.async {
    // Work that impacts the user interface.
}
```

### App extension support

An app extension typically encounters item providers when examining the [`attachments`](/documentation/Foundation/NSExtensionItem/attachments) property of an [`NSExtensionItem`](/documentation/Foundation/NSExtensionItem) object. During that examination, the extension can use the [`hasItemConformingToTypeIdentifier(_:)`](/documentation/Foundation/NSItemProvider/hasItemConformingToTypeIdentifier(_:)) method to look for data that it recognizes. Item providers use <doc://com.apple.documentation/documentation/UniformTypeIdentifiers> values to identify the data they contain. After finding a type of data that your extension can use, it calls the [`loadItem(forTypeIdentifier:options:completionHandler:)`](/documentation/Foundation/NSItemProvider/loadItem(forTypeIdentifier:options:completionHandler:)) 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 [`previewImageHandler`](/documentation/Foundation/NSItemProvider/previewImageHandler) 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 [`registerItem(forTypeIdentifier:loadHandler:)`](/documentation/Foundation/NSItemProvider/registerItem(forTypeIdentifier:loadHandler:)) 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.

## Topics

### Creating an item provider

[`init(contentsOf:)`](/documentation/Foundation/NSItemProvider/init(contentsOf:))

Provides data-backed content from an existing file.

[`init(contentsOf:contentType:openInPlace:coordinated:visibility:)`](/documentation/Foundation/NSItemProvider/init(contentsOf:contentType:openInPlace:coordinated:visibility:))

Provides data-backed content from an existing file with the specified parameters.

[`initWithContentsOfURL:contentType:openInPlace:coordinated:visibility:`](/documentation/Foundation/NSItemProvider/initWithContentsOfURL:contentType:openInPlace:coordinated:visibility:)

Provides data-backed content from an existing file with the specified parameters.

[`init(item:typeIdentifier:)`](/documentation/Foundation/NSItemProvider/init(item:typeIdentifier:))

Creates an item provider with an object, according to the item provider type coercion policy.

[`init()`](/documentation/Foundation/NSItemProvider/init())

Creates an empty item provider to which you can later register a data or file representation.

[`init(object:)`](/documentation/Foundation/NSItemProvider/init(object:))

Creates a new item provider, employing a specified object’s type identifiers to specify the data representations eligible for the provider to load.

### Configuring the provider

[`preferredPresentationSize`](/documentation/Foundation/NSItemProvider/preferredPresentationSize)

The ideal presentation size of the item.

[`preferredPresentationStyle`](/documentation/Foundation/NSItemProvider/preferredPresentationStyle-swift.property)

The preferred style for presenting the item provider’s data.

[`NSItemProvider.PreferredPresentationStyle`](/documentation/Foundation/NSItemProvider/PreferredPresentationStyle-swift.enum)

The presentation styles that determine how a view shows an item provider’s data.

[`suggestedName`](/documentation/Foundation/NSItemProvider/suggestedName)

The filename to use when writing the provided data to a file on disk.

[`teamData`](/documentation/Foundation/NSItemProvider/teamData)

The collection of data an app uses to hold private team information during drag and drop.

### Querying the provider’s contents

[`canLoadObject(ofClass:)`](/documentation/Foundation/NSItemProvider/canLoadObject(ofClass:)-3eig9)

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

[`canLoadObject(ofClass:)`](/documentation/Foundation/NSItemProvider/canLoadObject(ofClass:)-40grc)

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

[`hasItemConformingToTypeIdentifier(_:)`](/documentation/Foundation/NSItemProvider/hasItemConformingToTypeIdentifier(_:))

Returns a Boolean value indicating whether an item provider contains a data representation conforming to a specified universal type identifier file options parameter with a value of zero.

[`hasRepresentationConforming(toTypeIdentifier:fileOptions:)`](/documentation/Foundation/NSItemProvider/hasRepresentationConforming(toTypeIdentifier:fileOptions:))

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

[`registeredTypeIdentifiers`](/documentation/Foundation/NSItemProvider/registeredTypeIdentifiers)

Returns the array of type identifiers for the item provider, in the same order they were registered.

[`registeredTypeIdentifiers(fileOptions:)`](/documentation/Foundation/NSItemProvider/registeredTypeIdentifiers(fileOptions:))

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

### Loading the provider’s contents

[`loadItem(forTypeIdentifier:options:completionHandler:)`](/documentation/Foundation/NSItemProvider/loadItem(forTypeIdentifier:options:completionHandler:))

Loads the item’s data and coerces it to the specified type.

[`loadDataRepresentation(forTypeIdentifier:completionHandler:)`](/documentation/Foundation/NSItemProvider/loadDataRepresentation(forTypeIdentifier:completionHandler:))

Asynchronously copies the provided, typed data into a generic data object, returning a progress object.

[`loadDataRepresentation(for:completionHandler:)`](/documentation/Foundation/NSItemProvider/loadDataRepresentation(for:completionHandler:))

Asynchronously copies the universal type data into a generic data object, returning a progress object.

[`loadDataRepresentationForContentType:completionHandler:`](/documentation/Foundation/NSItemProvider/loadDataRepresentationForContentType:completionHandler:)

Asynchronously copies the provided, typed data into a generic data object, returning a progress object.

[`loadFileRepresentation(forTypeIdentifier:completionHandler:)`](/documentation/Foundation/NSItemProvider/loadFileRepresentation(forTypeIdentifier:completionHandler:))

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

[`loadFileRepresentation(for:openInPlace:completionHandler:)`](/documentation/Foundation/NSItemProvider/loadFileRepresentation(for:openInPlace:completionHandler:))

Asynchronously writes a copy of the universal type data to a temporary file, returning a progress object.

[`loadFileRepresentationForContentType:openInPlace:completionHandler:`](/documentation/Foundation/NSItemProvider/loadFileRepresentationForContentType:openInPlace:completionHandler:)

Asynchronously copies the content type data into a generic data object with the specified parameters.

[`loadInPlaceFileRepresentation(forTypeIdentifier:completionHandler:)`](/documentation/Foundation/NSItemProvider/loadInPlaceFileRepresentation(forTypeIdentifier:completionHandler:))

Asynchronously opens a file in place, if possible, returning a progress object.

[`loadObject(ofClass:completionHandler:)`](/documentation/Foundation/NSItemProvider/loadObject(ofClass:completionHandler:)-8ak5d)

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

[`loadObject(ofClass:completionHandler:)`](/documentation/Foundation/NSItemProvider/loadObject(ofClass:completionHandler:)-6pysm)

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

[`loadTransferable(type:completionHandler:)`](/documentation/Foundation/NSItemProvider/loadTransferable(type:completionHandler:))

Asynchronously loads an object of a specified transferable type to an item provider, returning a progress object.

### Loading a preview image

[`loadPreviewImage(options:completionHandler:)`](/documentation/Foundation/NSItemProvider/loadPreviewImage(options:completionHandler:))

Loads the preview image for the item that the item provider represents.

[`previewImageHandler`](/documentation/Foundation/NSItemProvider/previewImageHandler)

The custom preview image handler block for the item provider.

### Registering CloudKit shares

[`registerCloudKitShare(_:container:)`](/documentation/Foundation/NSItemProvider/registerCloudKitShare(_:container:))

Registers a CloudKit share for the user to modify.

[`registerCloudKitShare(preparationHandler:)`](/documentation/Foundation/NSItemProvider/registerCloudKitShare(preparationHandler:))

Registers a handler that prepares a new CloudKit share.

[`registerCKShare(_:container:allowedSharingOptions:)`](/documentation/Foundation/NSItemProvider/registerCKShare(_:container:allowedSharingOptions:))

Registers an existing collaboration object on a server.

[`registerCKShare(container:allowedSharingOptions:preparationHandler:)`](/documentation/Foundation/NSItemProvider/registerCKShare(container:allowedSharingOptions:preparationHandler:))

Creates and registers a new collaboration object using a collection of records to share.

[`registerCKShare:container:allowedSharingOptions:`](/documentation/Foundation/NSItemProvider/registerCKShare:container:allowedSharingOptions:)

Registers an existing collaboration object on a server.

[`registerCKShareWithContainer:allowedSharingOptions:preparationHandler:`](/documentation/Foundation/NSItemProvider/registerCKShareWithContainer:allowedSharingOptions:preparationHandler:)

Creates and registers a new collaboration object using a collection of records to share.

### Registering content types

[`registeredContentTypes`](/documentation/Foundation/NSItemProvider/registeredContentTypes)

Registered content types in the order the app registers each type.

[`registeredContentTypesForOpenInPlace`](/documentation/Foundation/NSItemProvider/registeredContentTypesForOpenInPlace)

Registered content types that the system can load as open-in-place files.

[`registeredContentTypes(conformingTo:)`](/documentation/Foundation/NSItemProvider/registeredContentTypes(conformingTo:))

Returns an array of registered content types that conform to a specified content type.

### Registering data

[`registerDataRepresentation(forTypeIdentifier:visibility:loadHandler:)`](/documentation/Foundation/NSItemProvider/registerDataRepresentation(forTypeIdentifier:visibility:loadHandler:))

Registers a data-backed representation for an item, specifiying item visibility and a load handler.

[`registerDataRepresentation(for:visibility:loadHandler:)`](/documentation/Foundation/NSItemProvider/registerDataRepresentation(for:visibility:loadHandler:))

Registers a data-backed representation for an item, specifiying item visibility and a load handler.

[`registerItem(forTypeIdentifier:loadHandler:)`](/documentation/Foundation/NSItemProvider/registerItem(forTypeIdentifier:loadHandler:))

Lazily registers an item, according to the item provider type coercion policy.

[`registerDataRepresentationForContentType:visibility:loadHandler:`](/documentation/Foundation/NSItemProvider/registerDataRepresentationForContentType:visibility:loadHandler:)

Lazily registers an item, according to the item provider type coercion policy.

### Registering files

[`registerFileRepresentation(forTypeIdentifier:fileOptions:visibility:loadHandler:)`](/documentation/Foundation/NSItemProvider/registerFileRepresentation(forTypeIdentifier:fileOptions:visibility:loadHandler:))

Registers a file-backed representation for an item, specifying file options, item visibility, and a load handler.

[`registerFileRepresentation(for:visibility:openInPlace:loadHandler:)`](/documentation/Foundation/NSItemProvider/registerFileRepresentation(for:visibility:openInPlace:loadHandler:))

Registers a file-backed representation for an item with item visibility, an open-in-place option, and a load handler.

[`registerFileRepresentationForContentType:visibility:openInPlace:loadHandler:`](/documentation/Foundation/NSItemProvider/registerFileRepresentationForContentType:visibility:openInPlace:loadHandler:)

Registers a file-backed representation for an item with item visibility, an open-in-place option, and a load handler.

### Registering group activities

[`registerGroupActivity(_:)`](/documentation/Foundation/NSItemProvider/registerGroupActivity(_:))

Registers a group activity instance with the specificed options.

[`registerGroupActivity(preparationHandler:)`](/documentation/Foundation/NSItemProvider/registerGroupActivity(preparationHandler:))

Registers a group activity instance asynchronously with the specified options.

### Registering objects

[`registerObject(_:visibility:)`](/documentation/Foundation/NSItemProvider/registerObject(_:visibility:))

Adds representations of a specified object to an item provider, based on the object’s implementation of the item provider writing protocol, and adhering to a visibility specification.

[`registerObject(ofClass:visibility:loadHandler:)`](/documentation/Foundation/NSItemProvider/registerObject(ofClass:visibility:loadHandler:)-9sndn)

Lazily adds representations of a specified object class to an item provider, based on the object’s implementation of the item provider writing protocol, and adhering to a visibility specification.

[`registerObject(ofClass:visibility:loadHandler:)`](/documentation/Foundation/NSItemProvider/registerObject(ofClass:visibility:loadHandler:)-133rx)

Lazily adds representations of a specified object type to an item provider, based on the object’s implementation of the item provider writing protocol, and adhering to a visibility specification.

[`register(_:)`](/documentation/Foundation/NSItemProvider/register(_:))

Adds representations of a specified transferable type to an item provider.

### Getting the provider’s frame

[`sourceFrame`](/documentation/Foundation/NSItemProvider/sourceFrame)

The rectangle that the item occupies in the host app’s source window.

[`containerFrame`](/documentation/Foundation/NSItemProvider/containerFrame)

The rectangle of the item’s visible content.

### Constants

[`NSItemProvider.CompletionHandler`](/documentation/Foundation/NSItemProvider/CompletionHandler)

A block that receives the item provider’s data.

[`NSItemProvider.LoadHandler`](/documentation/Foundation/NSItemProvider/LoadHandler)

A block that loads the item provider’s data and coerces it to the specified type.

[Options Dictionary Key](/documentation/Foundation/options-dictionary-key)

Keys indicating options to use when generating the item provider’s data.

[Keys for Items Accessed in JavaScript Code](/documentation/Foundation/keys-for-items-accessed-in-javascript-code)

Keys in property list items that the system recieves from or sends to JavaScript code.

[`errorDomain`](/documentation/Foundation/NSItemProvider/errorDomain)

The error domain associated with the item provider.

[`NSItemProviderFileOptions`](/documentation/Foundation/NSItemProviderFileOptions)

Data-access specifications that declare how to handle items.

[`NSItemProviderReading`](/documentation/Foundation/NSItemProviderReading)

The protocol for implementing a class to allow an item provider to create an instance of the class.

[`NSItemProviderWriting`](/documentation/Foundation/NSItemProviderWriting)

The protocol for implementing a class to allow an item provider to retrieve data from an instance of the class.

[`NSItemProviderRepresentationVisibility`](/documentation/Foundation/NSItemProviderRepresentationVisibility)

Specifications that control which categories of processes can see an item.

[`NSItemProvider.ErrorCode`](/documentation/Foundation/NSItemProvider/ErrorCode)

The error codes that describe problems with consuming data from an item provider.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)