Class

HKObjectType

The abstract superclass for all classes that identify a specific type of data when working with 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.

Using Object Types

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 Quantity Types

class func quantityType(forIdentifier: HKQuantityTypeIdentifier) -> HKQuantityType?

Returns the shared quantity type for the provided identifier.

struct HKQuantityTypeIdentifier

Used to define the identifiers that create quantity type objects.

Creating Category Types

class func categoryType(forIdentifier: HKCategoryTypeIdentifier) -> HKCategoryType?

Returns the shared category type for the provided identifier.

struct HKCategoryTypeIdentifier

Used to define the identifiers that create category type objects.

Creating Characteristic Types

struct HKCharacteristicTypeIdentifier

Used to define the identifiers that create characteristic type objects.

Creating Correlation Types

class func correlationType(forIdentifier: HKCorrelationTypeIdentifier) -> HKCorrelationType?

Returns the shared correlation type for the provided identifier.

struct HKCorrelationTypeIdentifier

Used to define the identifiers that create correlation type objects.

Creating Workout Types

Creating Activity Summary Types

class func activitySummaryType() -> HKActivitySummaryType

Returns the shared activity summary type.

Creating Clinical Record Types

class func clinicalType(forIdentifier: HKClinicalTypeIdentifier) -> HKClinicalType?

Returns the shared clinical type for the provided identifier.

Beta

Creating Series types

class func seriesType(forIdentifier: String) -> HKSeriesType?

Returns the shared series type for the provided identifier.

Creating Document Types

class func documentType(forIdentifier: HKDocumentTypeIdentifier) -> HKDocumentType?

Returns the shared document type for the provided identifier.

struct HKDocumentTypeIdentifier

Used to define the identifiers that create document type objects.

Getting Property Data

var identifier: String

A unique string identifying the HealthKit object type.

Relationships

Inherits From

See Also

Type Objects

class HKCharacteristicType

Characteristic types represent data that does not typically change over time.

class HKQuantityType

Quantity types identify samples that store numerical values.

class HKCategoryType

Category types identify samples that contain a value from a small set of possible values.

class HKCorrelationType

Correlation types identify samples that group multiple subsamples.

class HKActivitySummaryType

Activity summary types identify activity summary objects.

class HKSeriesType

An identifier that indicates the type for data stored in a series sample.

class HKSampleType

An abstract superclass for all classes that identify a specific type of sample when working with the HealthKit store.

class HKClinicalType

Clinical types identify samples that contain clinical record data.

Beta

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