Class

HKObjectType

HealthKit uses HKObjectType instances to store type information about data saved in the HealthKit store.

Overview

The HKObjectType class is an abstract class. You should never instantiate an HKObjectType object directly. Instead, you always work with one of the following concrete subclasses:

The HKObjectType class provides a convenience method to create each of these subclasses.

Subclassing Notes

Like many HealthKit classes, HealthKit object types are not extensible and should not be subclassed.

Additionally, wherever possible, this class uses a single instance to represent all copies of the same type. For example, if two calls to the quantityType(forIdentifier:) method are passed the same identifier, they return the same instance. Reusing object types helps reduce HealthKit’s overall memory usage.

Letting multiple HealthKit objects share the same object type instance helps reduce the overall memory usage.

Topics

Creating Subclasses

class func categoryType(forIdentifier: HKCategoryTypeIdentifier)

Returns the shared HKCategoryType object for the provided identifier.

class func characteristicType(forIdentifier: HKCharacteristicTypeIdentifier)

Returns the shared HKCharacteristicType object for the provided identifier.

class func documentType(forIdentifier: HKDocumentTypeIdentifier)

Returns the shared HKDocumentType object for the provided identifier.

class func quantityType(forIdentifier: HKQuantityTypeIdentifier)

Returns the shared HKQuantityType object for the provided identifier.

class func workoutType()

Returns the shared HKWorkoutType object.

Getting Property Data

var identifier: String

A unique string identifying the HealthKit object type.

Relationships

Inherits From

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software