<!--
{
  "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/PHAssetCreationRequest/addResource(with:data:options:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Photos"
    ],
    "preciseIdentifier" : "c:objc(cs)PHAssetCreationRequest(im)addResourceWithType:data:options:"
  },
  "title" : "addResource(with:data:options:)"
}
-->

# addResource(with:data:options:)

Adds a data resource to the asset being created, using the specified data.

```
func addResource(with type: PHAssetResourceType, data: Data, options: PHAssetResourceCreationOptions?)
```

## Parameters

`type`

The role of this data resource in constructing an asset. For details, see [`PHAssetResourceType`](/documentation/Photos/PHAssetResourceType).

`data`

The data for the asset resource.

`options`

Options affecting how Photos constructs the asset resource and incorporates its data into the Photos library. For details, see [`PHAssetResourceCreationOptions`](/documentation/Photos/PHAssetResourceCreationOptions).

## Discussion

Photos imports the asset resource data only when it executes the [`PHPhotoLibrary`](/documentation/Photos/PHPhotoLibrary) change block in which you create a [`PHAssetCreationRequest`](/documentation/Photos/PHAssetCreationRequest) object and call this method. If you attempt to create an asset with invalid data or an invalid combination of resources, Photos reports an error in the completion handler of your [`PHPhotoLibrary`](/documentation/Photos/PHPhotoLibrary) call.

---

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)