<!--
{
  "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/HKQuantity/doubleValue(for:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "HealthKit"
    ],
    "preciseIdentifier" : "c:objc(cs)HKQuantity(im)doubleValueForUnit:"
  },
  "title" : "doubleValue(for:)"
}
-->

# doubleValue(for:)

Returns the quantity’s value in the provided unit.

```
func doubleValue(for unit: HKUnit) -> Double
```

## Parameters

`unit`

The target unit. If the quantity is not compatible with this unit, it throws an exception (<doc://com.apple.documentation/documentation/Foundation/NSExceptionName/invalidArgumentException>).

## Return Value

The quantity’s value in the provided units.

## Discussion

This method converts the quantity’s value to the desired units. You do not need to know the quantity’s original units. You can request the value in whatever units you want, as long as they are compatible with the quantity. This lets each application (or each locale) work with its preferred units.

In most cases, you know which units are compatible with a given quantity from context. To see the unit types associated with different quantity sample types, see the type identifiers in [`HKQuantityTypeIdentifier`](/documentation/HealthKit/HKQuantityTypeIdentifier).

If you need to programmatically check whether a particular unit is compatible with a particular quantity, call the quantity’s [`is(compatibleWith:)`](/documentation/HealthKit/HKQuantity/is(compatibleWith:)) method.

---

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)