Class

HKObject

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

Overview

The HKObject class is an abstract class. You should never instantiate a HKObject object directly. Instead, always work with one of its concrete subclasses: HKCategorySample, HKQuantitySample, HKCorrelation, or HKWorkout.

HealthKit objects are all immutable. With a few exceptions (such as the object’s source revision), the object’s properties are set when the object is first created and they cannot change.

Subclassing Notes

Like many HealthKit classes, the HKObject class should not be subclassed. You can extend HKObject and its subclasses by adding custom metadata keys and values to the metadata dictionary when the object is created.

Topics

Getting Properties

var uuid: UUID

The universally unique identifier (UUID) for this HealthKit object.

var metadata: [String : Any]?

The metadata for this HealthKit object.

var device: HKDevice?

The device that generated the data for this object.

var source: HKSource

A HealthKit source, representing the app or device that created this object.

Deprecated
var sourceRevision: HKSourceRevision

The app or device that created this object.

Constants

Predicate Key Paths

Key paths for constructing predicates for querying HealthKit objects. For more information, see Predicate Format String Syntax

Relationships

Inherits From