<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 13.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "HealthKit",
  "identifier" : "/documentation/HealthKit/HKQuantityType/is(compatibleWith:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "HealthKit"
    ],
    "preciseIdentifier" : "c:objc(cs)HKQuantityType(im)isCompatibleWithUnit:"
  },
  "title" : "is(compatibleWith:)"
}
-->

# is(compatibleWith:)

Returns a Boolean value that indicates whether the quantity type is compatible with the given unit.

```
func `is`(compatibleWith unit: HKUnit) -> Bool
```

## Parameters

`unit`

The HealthKit unit to be checked.

## Return Value

YES if the quantity type is compatible with the given unit; otherwise, NO.

## Discussion

When creating a HealthKit quantity sample, the sample’s type and quantity object must use compatible units. For more information, see [`HKQuantity`](/documentation/HealthKit/HKQuantity).

---

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)