Instance Property


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


var predicate: NSPredicate? { get set }


Construct a predicate with the properties of the class of objects that you want to fetch, listed in Table 1. For example, the following code uses a predicate to fetch assets matching a specific set of mediaSubtypes values:

PHFetchOptions* fetchOptions = [PHFetchOptions new];
fetchOptions.predicate = [NSPredicate predicateWithFormat:@"(mediaSubtypes & %d) != 0 || (mediaSubtypes & %d) != 0", PHAssetMediaSubtypePhotoPanorama, PHAssetMediaSubtypeVideoHighFrameRate];
PHFetchResult* fetchResult = [PHAsset fetchAssetsWithOptions:fetchOptions];

Photos does not support predicates created with the init(block:) method.

See Also

Sorting and Filtering Fetch Results

var sortDescriptors: [NSSortDescriptor]?

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

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