---
title: "jouleUnit(with:)"
framework: healthkit
role: symbol
role_heading: Type Method
path: "healthkit/hkunit/jouleunit(with:)"
---

# jouleUnit(with:)

Returns a HealthKit unit for measuring energy, using joule units with the provided prefix.

## Declaration

```swift
class func jouleUnit(with prefix: HKMetricPrefix) -> Self
```

## Parameters

- `prefix`: A valid metric prefix value. For the complete list of prefix values, see doc://com.apple.healthkit/documentation/HealthKit/HKMetricPrefix.

## Return Value

Return Value A HealthKit unit for measuring energy based on joules and the provided prefix.

## Discussion

Discussion This method is used to create prefixed versions of joules. HealthKit commonly uses kilojoules to measure food energy in many regions. Kilojoules can be created as shown below.

## See Also

### Constructing energy units

- [joule()](healthkit/hkunit/joule().md)
- [kilocalorie()](healthkit/hkunit/kilocalorie().md)
- [largeCalorie()](healthkit/hkunit/largecalorie().md)
- [smallCalorie()](healthkit/hkunit/smallcalorie().md)
- [calorie()](healthkit/hkunit/calorie().md)
