Class

PHAssetCreationRequest

A request to create a new Photos asset from underlying data resources, for use in a photo library change block.

Declaration

@interface PHAssetCreationRequest : PHAssetChangeRequest

Overview

A PHAssetCreationRequest object, used within a photo library change block, constructs a new photo or video asset from data resources, and adds it to the Photos library. This class works in terms of the raw data resources that together form an asset, so you can use it together with the PHAssetResource class to perform a complete copy (or backup and restore) of an asset’s underlying resources. To instead simply create a new asset from an image object, image file, or video file, see the superclass PHAssetChangeRequest.

To create a new asset from data resources, first start a change block using the shared PHPhotoLibrary method performChanges:completionHandler: or performChangesAndWait:error:. Then, within the change block:

  1. Within the change block, create a new asset creation request with the creationRequestForAsset method.

  2. Add image, video, or data resources using the methods listed in Providing Data Resources for the New Asset.

  3. (Optional.) Set metadata for the new asset using methods and properties of the superclass PHAssetChangeRequest.

After Photos runs the change block and calls your completion handler, the new asset is created in the Photos library.

If you instantiate or use this class outside a photo library change block, Photos throws an exception. For details on change blocks, see PHPhotoLibrary.

Topics

Requesting Asset Creation

+ creationRequestForAsset

Creates a request for adding a new asset to the Photos library using asset resources.

Preflighting a Request

+ supportsAssetResourceTypes:

Returns a Boolean value indicating whether Photos supports creating an asset with the specified combination of resource types.

Providing Data Resources for the New Asset

- addResourceWithType:data:options:

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

- addResourceWithType:fileURL:options:

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

Relationships

See Also

Asset Resource Management

PHAssetResource

An underlying data resource associated with a photo, video, or Live Photo asset in the Photos library.

PHAssetResourceCreationOptions

A set of options affecting the creation of a new Photos asset from underlying resources.

PHAssetResourceManager

A resource manager for the data storage underlying a Photos asset.

PHAssetResourceRequestOptions

A set of options affecting the delivery of underlying asset data that you request from the asset resource manager.