PHCollectionList
PHCollectionList
PHCollectionList Class of Photos A group containing Photos asset collections, such as Moments, Years, or folders of user-created albums.
class PHCollectionListOverview
In the Photos framework, collection objects (including asset collections) do not directly reference their member objects, and there are no other objects that directly reference collection objects. To retrieve the members of a collection list, fetch them with a PHCollection class method such as fetchCollections(in:options:)). To find objects at the root of the collection list hierarchy (such as album folders with no parent folders), use the fetchTopLevelUserCollections(with:)) method.
Important: Accessing or modifying the Photos library requires explicit authorization from the user. The first time you call one of the methods listed in the Fetching Collection Lists group, Photos automatically prompts the user for authorization. (Alternatively, you can use the `
doc://com.apple.photokit/documentation/Photos/PHPhotoLibrarydoc://com.apple.photokit/documentation/Photos/PHPhotoLibrary/requestAuthorization(_:)` method to prompt the user at a time of your choosing.)Your app’s
Info.plistfile must provide a value for the NSPhotoLibraryUsageDescription key that explains to the user why your app is requesting Photos access. Apps linked on or after iOS 10.0 will crash if this key is not present.
Like assets and asset collections, collection lists are immutable. To create, rename, or delete collection lists, or to add, remove, or rearrange members in a collection list, create a PHCollectionListChangeRequest object within a photo library change block. For details on using change requests and change blocks to update the photo library, see PHPhotoLibrary.