---
title: "is(compatibleWith:)"
framework: healthkit
role: symbol
role_heading: Instance Method
path: "healthkit/hkquantitytype/is(compatiblewith:)"
---

# is(compatibleWith:)

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

## Declaration

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

## Parameters

- `unit`: The HealthKit unit to be checked.

## Return Value

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

## Discussion

Discussion When creating a HealthKit quantity sample, the sample’s type and quantity object must use compatible units. For more information, see HKQuantity.

## See Also

### Accessing Quantity Type Data

- [aggregationStyle](healthkit/hkquantitytype/aggregationstyle.md)
- [HKQuantityAggregationStyle](healthkit/hkquantityaggregationstyle.md)
