A sample that represents the quantity (both the value and units) of a single measurement.
- iOS 8.0+
- watchOS 2.0+
Each quantity sample represent a piece of data with a single numeric value and the value’s associated units. For example, you can use a quantity sample to record the user’s height, the user’s current heart rate, or the number of calories in a hamburger. HealthKit provides a wide range of quantity types, letting you track a number of different health and fitness features.
HKQuantity class is a concrete subclass of the
HKSample class. Quantity samples are immutable: You set the sample’s properties when you create it, and they cannot change.
Using Quantity Samples
Like many HealthKit classes, the
HKQuantity class should not be subclassed.
You may extend the
HKQuantity class by adding metadata with custom keys as appropriate for your app. For more information, see