addResource(with:data:options:)
Adds a data resource to the asset being created, using the specified data.
Declaration
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.
- 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.
Discussion
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.