<!--
{
  "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/init(unit:doubleValue:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "HealthKit"
    ],
    "preciseIdentifier" : "c:objc(cs)HKQuantity(cm)quantityWithUnit:doubleValue:"
  },
  "title" : "init(unit:doubleValue:)"
}
-->

# init(unit:doubleValue:)

Instantiates and returns a new quantity object.

```
convenience init(unit: HKUnit, doubleValue value: Double)
```

## Parameters

`unit`

The units for the given value. This defines the set of compatible units. For example, if you create a quantity with a meter unit, it is compatible with any other length units.

`value`

The value of this quantity, measured using the unit parameter.

## Return Value

A newly instantiated quantity instance.

## Discussion

HealthKit uses quantity objects to store data for quantity samples. For more information on using quantity objects, see [`HKQuantitySample`](/documentation/HealthKit/HKQuantitySample).

---

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)