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

# lengthFormatterUnit(from:)

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

```
class func lengthFormatterUnit(from unit: HKUnit) -> LengthFormatter.Unit
```

## Parameters

`unit`

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

## Return Value

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

## 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)