A sample that groups multiple related samples into a single entry.
- iOS 8.0+
- Mac Catalyst 13.0+
- watchOS 2.0+
HealthKit uses correlations to represent both blood pressure and food.
Blood pressure correlations always include two quantity samples, representing the systolic and diastolic values.
Food correlations can contain a wide range of dietary information about the food, including information about the fat, protein, carbohydrates, energy, and vitamins consumed.
In general, a food correlation should include at least a
dietary sample. You can also add nutritional quantity samples for any other items you want to track. Use the
HKMetadata key to indicate the food’s name.
HKCorrelation class is a concrete subclass of the
HKSample class. Correlations are immutable: You set the correlation’s properties when the object is first created, and they cannot change.
Using Correlation Samples
Like many HealthKit classes, the
HKCorrelation class should not be subclassed. You can extend the correlation class by adding metadata with custom keys as appropriate for your app. For more information, see the