A predicate that specifies which properties to select results by and that also specifies any constraints on selection.
SDKs
- iOS 8+
- macOS 10.13+
- Mac Catalyst 13.0+
- tvOS 10+
Framework
- Photos
Declaration
var predicate: NSPredicate? { get set }
Discussion
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 media
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.