---
title: "massFormatterUnit(from:)"
framework: healthkit
role: symbol
role_heading: Type Method
path: "healthkit/hkunit/massformatterunit(from:)"
---

# massFormatterUnit(from:)

Converts a HealthKit unit object into a corresponding mass formatter enumeration value.

## Declaration

```swift
class func massFormatterUnit(from unit: HKUnit) -> MassFormatter.Unit
```

## Parameters

- `unit`: A valid HealthKit unit object. If the unit is not a mass-type unit, this method throws an exception (doc://com.apple.documentation/documentation/Foundation/NSExceptionName/invalidArgumentException).

## Return Value

Return Value A mass formatter unit value. For a list of possible mass formatter unit values, see MassFormatter.Unit.

## See Also

### Working with formatter units

- [energyFormatterUnit(from:)](healthkit/hkunit/energyformatterunit(from:).md)
- [init(from:)](healthkit/hkunit/init(from:)-1j1pq.md)
- [lengthFormatterUnit(from:)](healthkit/hkunit/lengthformatterunit(from:).md)
- [init(from:)](healthkit/hkunit/init(from:)-55e1u.md)
- [init(from:)](healthkit/hkunit/init(from:)-7h2li.md)
