---
title: "predicateForSamples(_:value:)"
framework: healthkit
role: symbol
role_heading: Type Method
path: "healthkit/hkcategoryvaluepredicateproviding/predicateforsamples(_:value:)"
---

# predicateForSamples(_:value:)

Returns a predicate that checks a category sample’s value.

## Declaration

```swift
static func predicateForSamples(_ operatorType: NSComparisonPredicate.Operator, value: Self) -> NSPredicate
```

## Parameters

- `operatorType`: The type of operation to perform when matching the category sample’s value against the target value. For a list of possible operators, see doc://com.apple.documentation/documentation/Foundation/NSComparisonPredicate/Operator/contains.
- `value`: The category sample’s target value. Use an enumeration value appropriate for the type of category samples you’re working with. For example, a predicate for sleep analysis samples use values from the doc://com.apple.healthkit/documentation/HealthKit/HKCategoryValueSleepAnalysis enumeration.

## See Also

### Creating predicates

- [predicateForSamples(equalTo:)](healthkit/hkcategoryvaluepredicateproviding/predicateforsamples(equalto:).md)
