---
title: "moleUnit(with:molarMass:)"
framework: healthkit
role: symbol
role_heading: Type Method
path: "healthkit/hkunit/moleunit(with:molarmass:)"
---

# moleUnit(with:molarMass:)

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

## Declaration

```swift
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 doc://com.apple.healthkit/documentation/HealthKit/HKMetricPrefix.
- `gramsPerMole`: The molar mass, in grams per mole, of the item to be weighed.

## Return Value

Return Value A HealthKit unit for measuring mass in moles.

## Discussion

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 constant.).

## See Also

### Constructing mass units

- [gram()](healthkit/hkunit/gram().md)
- [gramUnit(with:)](healthkit/hkunit/gramunit(with:).md)
- [ounce()](healthkit/hkunit/ounce().md)
- [pound()](healthkit/hkunit/pound().md)
- [stone()](healthkit/hkunit/stone().md)
- [moleUnit(withMolarMass:)](healthkit/hkunit/moleunit(withmolarmass:).md)
- [HKUnitMolarMassBloodGlucose](healthkit/hkunitmolarmassbloodglucose.md)
