<!--
{
  "availability" : [
    "iOS: 15.4.0 -",
    "iPadOS: 15.4.0 -",
    "macCatalyst: 15.4.0 -",
    "macOS: 13.0.0 -",
    "visionOS: -",
    "watchOS: 8.5.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "HealthKit",
  "identifier" : "/documentation/HealthKit/HKSamplePredicate/quantitySample(type:predicate:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "HealthKit"
    ],
    "preciseIdentifier" : "s:9HealthKit17HKSamplePredicateV14quantitySample4type9predicateACySo010HKQuantityF0CGSo0I4TypeC_So11NSPredicateCSgtFZ"
  },
  "title" : "quantitySample(type:predicate:)"
}
-->

# quantitySample(type:predicate:)

Returns a sample predicate that matches quantity samples.

```
static func quantitySample(type quantityType: HKQuantityType, predicate: NSPredicate? = nil) -> HKSamplePredicate<HKQuantitySample>
```

## Parameters

`quantityType`

A type that matches samples that store numerical values.

`predicate`

An optional predicate that further restricts the results that the query returns.

## Discussion

Use this method to create an [`HKSamplePredicate`](/documentation/HealthKit/HKSamplePredicate) instance that you can use to query for [`HKQuantitySample`](/documentation/HealthKit/HKQuantitySample) objects.

---

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)