Contents

PHAssetChangeRequest

A request to create, delete, change metadata for, or edit the content of a Photos asset, for use in a photo library change block.

Declaration

class PHAssetChangeRequest

Mentioned in

Overview

You use the PHAssetChangeRequest class to request changes for PHAsset objects. To make changes to assets in the Photos library, create a change request by using the appropriate class method for the change you want to perform.

  • Call one of the methods listed in Adding New Assets to create a new asset from an image or video file.

  • Call the deleteAssets(_:) method to delete existing assets.

  • Call the init(for:) method to modify an asset’s content or metadata.

A change request for creating or modifying an asset works like a mutable version of the asset object. Use the change request’s properties to request changes to the corresponding properties of the asset itself. For example, the following code uses the isFavorite property of a change request to mark an asset as a favorite:

After Photos runs the change block and calls your completion handler, the asset’s state reflects the changes that you requested in the block.

If you create or use a change request object outside a photo library change block, Photos raises an Objective-C exception. For details on change blocks, see PHPhotoLibrary.

Topics

Adding New Assets

Deleting Assets

Modifying Assets

Editing Asset Content

Initializers

See Also

Updating the Library