<!--
{
  "availability" : [
    "iOS: 9.0.0 -",
    "iPadOS: 9.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.15.0 -",
    "tvOS: 10.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "PhotoKit",
  "identifier" : "/documentation/Photos/PHAssetResourceManager/requestData(for:options:dataReceivedHandler:completionHandler:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Photos"
    ],
    "preciseIdentifier" : "c:objc(cs)PHAssetResourceManager(im)requestDataForAssetResource:options:dataReceivedHandler:completionHandler:"
  },
  "title" : "requestData(for:options:dataReceivedHandler:completionHandler:)"
}
-->

# requestData(for:options:dataReceivedHandler:completionHandler:)

Requests the underlying data for the specified asset resource, to be delivered asynchronously.

```
func requestData(for resource: PHAssetResource, options: PHAssetResourceRequestOptions?, dataReceivedHandler handler: @escaping (Data) -> Void, completionHandler: @escaping ((any Error)?) -> Void) -> PHAssetResourceDataRequestID
```

## Parameters

`resource`

The asset resource for which to request data.

`options`

Options specifying how Photos should handle the request and notify your app of progress. For details, see [`PHAssetResourceRequestOptions`](/documentation/Photos/PHAssetResourceRequestOptions).

`handler`

A block that Photos calls to provide the requested data.

    The block takes a single parameter:

- data: The requested asset resource data.

`completionHandler`

A block that photos calls after the request has been fulfilled or has failed.

    The block takes a single parameter:

- error: If the request has failed, an `NSError` object describing the failure; otherwise `nil`.

## Return Value

A numeric identifier for the request. If you need to cancel the request before it completes, pass this identifier to the [`cancelDataRequest(_:)`](/documentation/Photos/PHAssetResourceManager/cancelDataRequest(_:)) method.

## Discussion

When you call this method, Photos begins asynchronously reading the underlying data for the asset resource. Depending on the options you specify and the current state of the asset, Photos may download asset data from the network.

While reading (or downloading) asset resource data, Photos calls your `handler` block at least once, progressively providing chunks of data. After reading all of the data, Photos calls your `completionHandler` block to indicate that the data is complete. (At this point, the complete data for the asset is the concatenation of the `data` parameters from all calls to your `handler` block.) If Photos cannot finish reading or downloading asset resource data, it calls your `completionHandler` block with a description of the error. Photos can also call the `completionHandler` block with a non-nil error when the data is complete if the user cancels downloading.

> Note:
> Photos calls your `handler` and `completionHandler` blocks on an arbitrary serial queue. To update the UI in response to these events, dispatch to the main queue.

---

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)