<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.13.0 -",
    "tvOS: 10.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "PhotoKit",
  "identifier" : "/documentation/Photos/PHFetchOptions/predicate",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Property",
  "symbol" : {
    "kind" : "Instance Property",
    "modules" : [
      "Photos"
    ],
    "preciseIdentifier" : "c:objc(cs)PHFetchOptions(py)predicate"
  },
  "title" : "predicate"
}
-->

# predicate

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

```
var predicate: NSPredicate? { get set }
```

## Discussion

Construct a predicate with the properties of the class of objects that you want to fetch, listed in the [`PHFetchOptions`](/documentation/Photos/PHFetchOptions) table. For example, the following code uses a predicate to fetch assets matching a specific set of [`mediaSubtypes`](/documentation/Photos/PHAsset/mediaSubtypes) values.

```swift
let format = "(mediaSubtypes & %d) != 0 || (mediaSubtypes & %d) != 0"
let fetchOptions = PHFetchOptions()
fetchOptions.predicate = NSPredicate(format: format,
                                     argumentArray: [PHAssetMediaSubtype.photoPanorama, PHAssetMediaSubtype.videoHighFrameRate])
        
let fetchResult = PHAsset.fetchAssets(with: PHAssetMediaType.image,
                                          options: fetchOptions)
```

Photos does not support predicates created with the `NSPredicate` method `init` or the `predicateWithBlock` method.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)