PHCollection

PHCollection

PHCollection Class of Photos The abstract superclass for Photos asset collections and collection lists.

class PHCollection

Overview

You do not create or work with instances of this class directly. Instead, use one of its two concrete subclasses, PHAssetCollection or PHCollectionList.

  • A `doc://com.apple.photokit/documentation/Photos/PHAssetCollection` object represents a collection of photo or video assets, such as an album, moment, or Shared Photo Stream.
  • A `doc://com.apple.photokit/documentation/Photos/PHCollectionList` object represents a collection that contains other collections, such as a a folder containing albums or the set of all moments in a calendar year.

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 Collections group, Photos automatically prompts the user for authorization. (Alternatively, you can use the `doc://com.apple.photokit/documentation/Photos/PHPhotoLibrary doc://com.apple.photokit/documentation/Photos/PHPhotoLibrary/requestAuthorization(_:)` method to prompt the user at a time of your choosing.)

Your app’s Info.plist file 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.