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.

Declaration

@interface PHFetchOptions : NSObject

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, favorite (or isFavorite), hidden (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

Topics

Sorting and Filtering Fetch Results

predicate

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

sortDescriptors

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

Subscribing to Changes

wantsIncrementalChangeDetails

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

Limiting Fetch Results

fetchLimit

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

includeAllBurstAssets

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

includeHiddenAssets

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

includeAssetSourceTypes

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

Relationships

Inherits From

Conforms To

See Also

Asset Retrieval

Fetching Objects and Requesting Changes

Get assets, asset collections, and collection lists matching a specified query.

PHAsset

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

PHAssetCollection

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

PHCollection

The abstract superclass for Photos asset collections and collection lists.

PHCollectionList

A group containing Photos asset collections, such as Moments, Years, or folders of user-created albums.

PHObject

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

PHFetchResult

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

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software