<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 13.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "HealthKit",
  "identifier" : "/documentation/HealthKit/HKUnit/init(from:)-7h2li",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "HealthKit"
    ],
    "preciseIdentifier" : "c:objc(cs)HKUnit(cm)unitFromMassFormatterUnit:"
  },
  "title" : "init(from:)"
}
-->

# init(from:)

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

```
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

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

## Discussion

---

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)