<!--
{
  "availability" : [
    "iOS: -",
    "iPadOS: -",
    "macCatalyst: -",
    "macOS: -",
    "visionOS: -",
    "watchOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "HealthKit",
  "identifier" : "/documentation/HealthKit/HKUnit/moleUnit(with:molarMass:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "HealthKit"
    ],
    "preciseIdentifier" : "c:objc(cs)HKUnit(cm)moleUnitWithMetricPrefix:molarMass:"
  },
  "title" : "moleUnit(with:molarMass:)"
}
-->

# moleUnit(with:molarMass:)

Returns a HealthKit unit for measuring mass in moles, with the given prefix and molar mass.

```
class func moleUnit(with prefix: HKMetricPrefix, molarMass gramsPerMole: Double) -> Self
```

## Parameters

`prefix`

A valid metric prefix value. For the complete list of prefix values, see [`HKMetricPrefix`](/documentation/HealthKit/HKMetricPrefix).

`gramsPerMole`

The molar mass, in grams per mole, of the item to be weighed.

## Return Value

A HealthKit unit for measuring mass in moles.

## Discussion

This method allows the creation of units to measure mass in moles with a given metric prefix and molecular mass. For example, to measure blood glucose in millimoles, you need to use both the correct prefix (milli-) and the [`HKUnitMolarMassBloodGlucose`](/documentation/HealthKit/HKUnitMolarMassBloodGlucose) constant.).

```swift
let millimolesOfBloodGlucose =
    HKUnit.moleUnitWithMetricPrefix(HKMetricPrefix.Milli,
                                    molarMass: HKUnitMolarMassBloodGlucose)
```

---

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)