Class

PHCollectionList

A representation of a group containing Photos asset collections, such as a moments year or a folder of user-created albums.

Overview

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.

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.

Topics

Fetching Collection Lists

class func fetchCollectionListsContaining(PHCollection, options: PHFetchOptions?)

Retrieves collection lists that contain the specified collection.

class func fetchCollectionLists(withLocalIdentifiers: [String], options: PHFetchOptions?)

Retrieves collection lists with the specified local-device-specific unique identifiers.

class func fetchMomentLists(with: PHCollectionListSubtype, containingMoment: PHAssetCollection, options: PHFetchOptions?)

Retrieves collection lists of the specified moment list type containing the specified moment.

class func fetchMomentLists(with: PHCollectionListSubtype, options: PHFetchOptions?)

Retrieves collection lists of the specified moment list type.

Reading Collection List Metadata

var collectionListType: PHCollectionListType

The type of asset collection group that the collection list represents.

enum PHCollectionListType

Major distinctions between kinds of collection list, used by the collectionListType property and fetchCollectionLists(with:subtype:options:) method.

var collectionListSubtype: PHCollectionListSubtype

The type of asset collection grouping the collection list represents.

var startDate: Date?

The earliest creation date among all assets in the collection list.

var endDate: Date?

The latest creation date among all assets in the collection list.

var localizedLocationNames: [String]

The names of locations grouped by the collection (an array of NSString objects).

Creating Temporary Collection Lists

class func transientCollectionList(with: [PHCollection], title: String?)

Creates a temporary collection list that contains the specified asset collections.

class func transientCollectionList(withCollectionsFetchResult: PHFetchResult<PHCollection>, title: String?)

Creates a temporary collection list containing the asset collections in the specified fetch result.

Relationships

Inherits From

See Also

Retrieving and Examining Assets

class PHAsset

A representation of an image, video or Live Photo in the Photos library.

class PHAssetCollection

A representation of a Photos asset grouping, such as a moment, user-created album, or smart album.

class PHCollection

The abstract superclass for Photos asset collections and collection lists.

class PHObject

The abstract superclass for Photos model objects (assets and collections).

class PHFetchResult

An ordered list of assets or collections returned from a Photos fetch method.

class PHFetchOptions

A set of options that affect the filtering, sorting, and management of results that Photos returns when you fetch asset or collection objects.