Class

PHObjectPlaceholder

A read-only proxy representing a Photos asset or collection object yet to be created by a change request.

Declaration

@interface PHObjectPlaceholder : PHObject

Overview

You obtain object placeholders when you use change requests to create assets, collections, or collection lists. After the change request completes, you can use the object placeholder to fetch the newly created object. You can also use an object placeholder to make additional change requests involving the object to be created.

For example, the following code uses a placeholder to add a newly created asset to an album:

PHAssetChangeRequest *createAssetRequest = [PHAssetChangeRequest creationRequestForAssetFromImage:image];
PHObjectPlaceholder *assetPlaceholder = createAssetRequest.placeholderForCreatedAsset;
PHAssetCollectionChangeRequest *albumChangeRequest =
    [PHAssetCollectionChangeRequest changeRequestForAssetCollection:album];
[albumChangeRequest addAssets:@[ assetPlaceholder ]];

A placeholder always has the same local identifier as the asset, collection, or collection list that it represents. To find the object that corresponds to a placeholder, read the placeholder’s localIdentifier property and use it to fetch the actual object. Alternatively, because the PHObjectPlaceholder class implements the isEqual: and hash methods in terms of its localIdentifier property, you can also find the object for a placeholder using techniques that depend on these methods.

Relationships

Inherits From

See Also

Applying Changes to the Photo Library

Requesting Changes to the Photo Library

Create, delete, or modify assets and collections in a photo library by making change requests.

- performChanges:completionHandler:

Asynchronously runs a block that requests changes to be performed in the photo library.

- performChangesAndWait:error:

Synchronously runs a block that requests changes to be performed in the photo library.

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.

PHAssetCollectionChangeRequest

A request to create, delete, or modify a Photos asset collection, for use in a photo library change block.

PHCollectionListChangeRequest

A request to create, delete, or modify a Photos collection list, for use in a photo library change block.