Create and save health and fitness samples.
Frameworks
- Health
Kit - Health
Kit UI
Overview
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 start
and 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:
HKQuantity
objects 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.Sample HKCategory
objects 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).Sample HKCorrelation
samples 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.HealthKit also uses other sample subclasses to represent more-specialized data types. For example,
HKCDADocument
,Sample HKWorkout
, andRoute HKWorkout
.