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.

Overview

Using class methods on the PHAsset, PHCollection, PHAssetCollection, and PHCollectionList classes to fetch assets or collections produces a PHFetchResult object containing the requested objects. The options you specify control which objects the fetch result includes, how those objects are arranged in the fetch result, and how Photos should notify your app of changes to the fetch result.

Photos supports only a restricted set of keys for the predicate and sortDescriptors properties. The set of available keys depends on which class you’re using to fetch assets or collections—see Table 1 for the list of keys supported by each class.

Table 1

Supported predicate and sort descriptor keys

Class for Fetch Method

Supported Keys

PHAsset

SELF, localIdentifier, creationDate, modificationDate, mediaType, mediaSubtypes, duration, pixelWidth, pixelHeight, isFavorite (or isFavorite), isHidden (or isHidden), burstIdentifier

PHAssetCollection

SELF, localIdentifier, localizedTitle (or title), startDate, endDate, estimatedAssetCount

PHCollectionList

SELF, localIdentifier, localizedTitle (or title), startDate, endDate

PHCollection (can fetch a mix of PHCollectionList and PHAssetCollection objects)

SELF, localIdentifier, localizedTitle (or title), startDate, endDate

Symbols

Sorting and Filtering Fetch Results

var predicate: NSPredicate?

A predicate that specifies which properties to select results by and that also specifies any constraints on selection.

var sortDescriptors: [NSSortDescriptor]?

A list of sort descriptors, specifying an order for the fetched objects.

Subscribing to Changes

var wantsIncrementalChangeDetails: Bool

A Boolean value that determines whether your app receives detailed change information for the objects in the fetch result.

Limiting Fetch Results

var fetchLimit: Int

The maximum number of objects to include in the fetch result.

var includeAllBurstAssets: Bool

A Boolean value that determines whether the fetch result includes all assets from burst photo sequences.

var includeHiddenAssets: Bool

A Boolean value that determines whether the fetch result includes assets marked as hidden.

var includeAssetSourceTypes: PHAssetSourceType

The set of source types for which to include assets in the fetch result.

Relationships

Inherits From