Create and save health and fitness samples.
Most health and fitness data is saved to the HealthKit store using an
HKSample subclass. All sample subclasses record information at a specified time. If the sample’s
end properties are the same, the sample represents a point in time. If the
end is after the
start, the sample represents a time interval.
HealthKit uses different
HKSample subclasses to store different types of data:
HKQuantityobjects store quantities—a numerical value and units. Most HealthKit data types use quantity samples. For example, height, heart rate, and dietary energy consumed all use quantity samples.
HKCategoryobjects store a single option selected from a short list. For example, sleep data is recorded using category samples (the user can be in bed, asleep, or awake).
HKCorrelationsamples combine two or more samples into a single value. For example, food and bloodpressure are represented using correlation samples. A food sample contains any number of nutrition samples, while a bloodpressure sample contains both a systolic and a diastolic sample.