<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.0.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSItemProvider/LoadHandler",
  "metadataVersion" : "0.1.0",
  "role" : "Type Alias",
  "symbol" : {
    "kind" : "Type Alias",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:@T@NSItemProviderLoadHandler"
  },
  "title" : "NSItemProvider.LoadHandler"
}
-->

# NSItemProvider.LoadHandler

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

```
typealias LoadHandler = @Sendable (NSItemProvider.CompletionHandler?, AnyClass?, [AnyHashable : Any]?) -> Void
```

## Discussion

Use this block when registering a type-specific coercion handler with the [`registerItem(forTypeIdentifier:loadHandler:)`](/documentation/Foundation/NSItemProvider/registerItem(forTypeIdentifier:loadHandler:)) method. The parameters for this block are as follows:

- completionHandler: The completion handler to call with the resulting data. For information about this block, see [`NSItemProvider.CompletionHandler`](/documentation/Foundation/NSItemProvider/CompletionHandler).
- expectedValueClass: The expected class of the item being loaded. Convert the item provider’s data to this type and pass the resulting object as the first parameter of the `completionHandler` block.
- options: A dictionary with options for how to provide the requested item. For example, the dictionary may contain the pixel dimensions of a requested image. For information about the supported keys, see [Options Dictionary Key](/documentation/Foundation/options-dictionary-key).

When a client calls the [`loadItem(forTypeIdentifier:options:completionHandler:)`](/documentation/Foundation/NSItemProvider/loadItem(forTypeIdentifier:options:completionHandler:)) method and requests the appropriate type, the item provider executes your block. In your implementation, create an object of the expected type and execute the block in the `completionHandler` parameter, passing the newly created object as the first parameter of that block. If there is an error, pass `nil` for the object and provide an appropriate [`NSError`](/documentation/Foundation/NSError) object explaining what happened.

This type of block is also used for generating preview images. In the case of a preview image, the `expectedValueClass` is always a [`NSData`](/documentation/Foundation/NSData), [`NSURL`](/documentation/Foundation/NSURL), <doc://com.apple.documentation/documentation/UIKit/UIImage> (in iOS), or <doc://com.apple.documentation/documentation/AppKit/NSImage> (in macOS) class.

---

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)