Contents

Data types

Specify the kind of data used in HealthKit.

Overview

HealthKit uses HKObjectType subclasses to identify the different types of data stored in HealthKit, from inherent data that doesn’t typically change over time to complex data types that combine multiple samples or compute values over sets of samples.

To create a type object, call the appropriate HKObjectType class method, and pass in the desired type identifier.

let bloodType = HKObjectType.characteristicType(forIdentifier: .bloodType)

let caloriesConsumed = HKObjectType.quantityType(forIdentifier: .dietaryEnergyConsumed)

let sleepAnalysis = HKObjectType.categoryType(forIdentifier: .sleepAnalysis)

You can use the resulting object types to request permission to access the data, save new data to the HealthKit store, or read data from the HealthKit store.

Topics

Object type subclasses

Characteristic identifiers

Activity

Attachments

Body measurements

Reproductive health

Hearing

Vital signs

Nutrition

Alcohol consumption

Mobility

Symptoms

Lab and test results

Mindfulness and sleep

Self care

Workouts

Clinical records

UV exposure

Vision

Diving

Utilities

See Also

Health data