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 startDate and endDate properties are the same, the sample represents a point in time. If the endDate is after the startDate, the sample represents a time interval.

HealthKit uses different HKSample subclasses to store different types of data:

  • HKQuantitySample 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.

  • HKCategorySample 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).

  • 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, HKCDADocumentSample, HKWorkoutRoute, and HKWorkout.



Saving Data to HealthKit

Create and share HealthKit samples.

Basic Samples


A sample that represents a cumulative quantity.


A sample that represents a discrete quantity.


A sample that represents a quantity, including the value and the units.


A sample whose values are selected from a short list of possible values.


A sample that groups multiple related samples into a single entry.

Units and Quantities

Objects used to specify a quantity for a given unit (for example, 175 lbs), and to convert between units (79.4 kg).

Metadata Keys

Constants used to add metadata to objects stored in HealthKit.

Series Data


A builder object for incrementally building a sample that contains multiple quantities.


A builder object for incrementally building a heartbeat series.


A sample that represents a series of heartbeats.



A sample that stores an audiogram.


A hearing sensitivity reading associated with a hearing test.

Medical Records

Accessing Health Records

Read clinical record data from the HealthKit store.

Accessing Sample Data in the Simulator

Set up sample accounts to build and test your app.


A sample that stores a clinical record.


An object containing Fast Healthcare Interoperability Resources (FHIR) data.


A Clinical Document Architecture (CDA) sample that stores a single document.


An abstract class that represents a health document in the HealthKit store.


The CDA Document type identifier, used when requesting permission to read or share CDA documents.


A sample type used to create queries for documents.

Digital Signatures

Adding Digital Signatures

Cryptographically sign samples.

Abstract Superclasses


A sample that represents a quantity, including the value and the units.


A HealthKit sample represents a piece of data associated with a start and end time.


A piece of data that can be stored inside the HealthKit store.

Deprecated Classes


A sample representing a series of cumulative quantity values.


See Also

Health Data

Saving Data to HealthKit

Create and share HealthKit samples.

Reading Data from HealthKit

Use queries to request sample data from HealthKit.

Data Types

Specify the kind of data used in HealthKit.


Query health and fitness data.