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


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 canPerform(_:) 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
    [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.


Adding New Collection Lists

class func creationRequestForCollectionList(withTitle: String)

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

var placeholderForCreatedCollectionList: PHObjectPlaceholder

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

Deleting Collection Lists

class func deleteCollectionLists(NSFastEnumeration)

Requests to delete the specified asset collections.

Modifying Collection Lists

init?(for: PHCollectionList)

Creates a request for modifying the specified collection list.

init?(for: PHCollectionList, childCollections: PHFetchResult<PHCollection>)

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

var title: String

The displayed name of the collection list.

func addChildCollections(NSFastEnumeration)

Add the specified collections as children of the collection list.

func insertChildCollections(NSFastEnumeration, at: IndexSet)

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

func removeChildCollections(NSFastEnumeration)

Removes the specified child collections from the collection list.

func removeChildCollections(at: IndexSet)

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

func replaceChildCollections(at: IndexSet, withChildCollections: NSFastEnumeration)

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

func moveChildCollections(at: IndexSet, to: Int)

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


Inherits From

Conforms To