Class

PHCollectionListChangeRequest

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

Declaration

@interface PHCollectionListChangeRequest : PHChangeRequest

Overview

You use the PHCollectionListChangeRequest class to request changes for PHCollectionList objects. To make changes to collection lists (such as folders containing user-created albums) in the Photos library, create a change request using the appropriate class method for the change you want to perform.

Before creating a change request, use the canPerformEditOperation: method to verify that the collection allows the edit operation you’re requesting. If you attempt to perform an unsupported edit operation, Photos throws an exception.

A change request for creating or modifying a collection list works like a mutable version of the collection list object. Use the change request’s properties and instance methods to request changes to the collection list itself. For example, the following code removes an album from a folder:

[[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{
    PHCollectionListChangeRequest *request = [PHCollectionListChangeRequest
        changeRequestForCollectionList:self.myFolder
                      childCollections:self.folderContentsFetchResult];
    [request removeChildCollections:@[ album ]];
 
} completionHandler:^(BOOL success, NSError *error) {
    NSLog(@"Finished removing album from the folder. %@", (success ? @"Success" : error));
}];

After Photos runs the change block and calls your completion handler, the collection list’s state reflects the changes 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 Collection Lists

+ creationRequestForCollectionListWithTitle:

Creates a request for adding a new collection list to the Photos library.

placeholderForCreatedCollectionList

A placeholder object for the collection list that the change request creates.

Deleting Collection Lists

+ deleteCollectionLists:

Requests to delete the specified asset collections.

Modifying Collection Lists

+ changeRequestForCollectionList:

Creates a request for modifying the specified collection list.

+ changeRequestForCollectionList:childCollections:

Creates a request for modifying the specified collection list, with a fetch result for tracking changes.

title

The displayed name of the collection list.

- addChildCollections:

Add the specified collections as children of the collection list.

- insertChildCollections:atIndexes:

Inserts the specified collections into the collection list at the specified indexes.

- removeChildCollections:

Removes the specified child collections from the collection list.

- removeChildCollectionsAtIndexes:

Removes the child collections at the specified indexes from the collection list.

- replaceChildCollectionsAtIndexes:withChildCollections:

Replaces the child collections at the specified indexes in the collection list with the specified collections.

- moveChildCollectionsAtIndexes:toIndex:

Moves the child collections at the specified indexes in the collection list to a new index.

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.

PHObjectPlaceholder

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