<!--
{
  "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/massFormatterUnit(from:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "HealthKit"
    ],
    "preciseIdentifier" : "c:objc(cs)HKUnit(cm)massFormatterUnitFromUnit:"
  },
  "title" : "massFormatterUnit(from:)"
}
-->

# massFormatterUnit(from:)

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

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

A mass formatter unit value. For a list of possible mass formatter unit values, see <doc://com.apple.documentation/documentation/Foundation/MassFormatter/Unit>.

---

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)