---
title: "gramUnit(with:)"
framework: healthkit
role: symbol
role_heading: Type Method
path: "healthkit/hkunit/gramunit(with:)"
---

# gramUnit(with:)

Returns a HealthKit unit for measuring mass, using gram units with the provided prefix.

## Declaration

```swift
class func gramUnit(with prefix: HKMetricPrefix) -> Self
```

## Parameters

- `prefix`: A valid metric prefix value. For the complete list of prefix values, see doc://com.apple.healthkit/documentation/HealthKit/HKMetricPrefix.

## Return Value

Return Value A HealthKit unit for measuring mass based on grams and the given prefix.

## Discussion

Discussion This method is used to create prefixed versions of grams, typically kilogram units, as shown below.

## See Also

### Constructing mass units

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