Instance Method


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


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



The role of this data resource in constructing an asset. For details, see PHAssetResourceType.


The data for the asset resource.


Options affecting how Photos constructs the asset resource and incorporates its data into the Photos library. For details, see PHAssetResourceCreationOptions.


Photos imports the asset resource data only when it executes the PHPhotoLibrary change block in which you create a 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 call.

See Also

Providing Data Resources for the New Asset

func addResource(with: PHAssetResourceType, fileURL: URL, options: PHAssetResourceCreationOptions?)

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