---
title: "init(from:)"
framework: healthkit
role: symbol
role_heading: Initializer
path: "healthkit/hkunit/init(from:)-7h2li"
---

# init(from:)

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

## Declaration

```swift
convenience init(from massFormatterUnit: MassFormatter.Unit)
```

## Parameters

- `massFormatterUnit`: A valid mass formatter unit value. For a list of possible mass formatter unit values, see doc://com.apple.documentation/documentation/Foundation/MassFormatter/Unit.

## Return Value

Return Value A HealthKit unit object, or nil if the unit parameter is not a valid energy formatter unit value.

## 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)
- [massFormatterUnit(from:)](healthkit/hkunit/massformatterunit(from:).md)
