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

# energyFormatterUnit(from:)

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

```
class func energyFormatterUnit(from unit: HKUnit) -> EnergyFormatter.Unit
```

## Parameters

`unit`

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

## Return Value

An energy formatter unit value. For a list of possible energy formatter unit values, see <doc://com.apple.documentation/documentation/Foundation/EnergyFormatter/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)