<!--
{
  "availability" : [
    "iOS: 16.0.0 -",
    "iPadOS: 16.0.0 -",
    "macCatalyst: 16.0.0 -",
    "macOS: 13.0.0 -",
    "visionOS: -",
    "watchOS: 9.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "HealthKit",
  "identifier" : "/documentation/HealthKit/HKCategoryValuePredicateProviding/predicateForSamples(_:value:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "HealthKit"
    ],
    "preciseIdentifier" : "s:9HealthKit33HKCategoryValuePredicateProvidingPAASi03RawD0RtzrlE19predicateForSamples_5valueSo11NSPredicateCSo0L12OperatorTypeV_xtFZ"
  },
  "title" : "predicateForSamples(_:value:)"
}
-->

# predicateForSamples(_:value:)

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

```
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 [`HKCategoryValueSleepAnalysis`](/documentation/HealthKit/HKCategoryValueSleepAnalysis) enumeration.

---

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)