An object that stores a value for a given unit.
- iOS 8.0+
- watchOS 2.0+
HealthKit uses quantity objects to store numerical data. When you create a quantity, you provide both the quantity’s value and unit.
Quantities are immutable objects: Their values are set when the object is first created and cannot change.
You can request the value from a quantity object in any compatible units. For example, if you create a length quantity in feet, you can then request the length in meters. The quantity object automatically converts its value to the requested units.
Like many HealthKit classes, the
HKQuantity class is not extendible and should not be subclassed. To help promote sharing data between apps,
HKQuantity objects use only the units defined by the