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

# lengthFormatterUnit(from:)

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

## Declaration

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

Return Value A length formatter unit value. For a list of possible length formatter unit values see LengthFormatter.Unit.

## See Also

### Working with formatter units

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