Returns a HealthKit unit for measuring energy, using joule units with the provided prefix.
SDKs
- iOS 8.0+
- Mac Catalyst 13.0+
- watchOS 2.0+
Framework
- Health
Kit
Declaration
class func jouleUnit(with prefix: HKMetric Prefix) -> Self
Parameters
prefix
A valid metric prefix value. For the complete list of prefix values, see
HKMetric
.Prefix
Return Value
A HealthKit unit for measuring energy based on joules and the provided prefix.
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.
let kj = HKUnit.jouleUnitWithMetricPrefix(.Kilo)