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.