Class

HKDiscreteQuantitySample

A sample that represents a discrete quantity.

Declaration

@interface HKDiscreteQuantitySample : HKQuantitySample

Overview

A quantity sample contains one or more HKQuantity objects. Each quantity represents a single piece of data with a single numeric value and the value’s associated units. Use these samples to store data representing independent measurements, such as height, heart rate, or temperature.

The HKDiscreteQuantitySample class is a concrete subclass of the HKQuantitySample class. Discrete quantity samples are immutable; you set the sample’s properties when you create it, and they cannot change.

Use Discrete Quantity Samples

Like many HealthKit classes, you should not subclass the HKDiscreteQuantitySample class. You may extend this class by adding metadata with custom keys to save related data used by your app. For more information, see quantitySampleWithType:quantity:startDate:endDate:metadata:.

Topics

Accessing Calculated Values

averageQuantity

The average of all quantities contained by the sample.

maximumQuantity

The maximum quantity contained by the sample.

minimumQuantity

The minimum value contained by the sample.

mostRecentQuantity

The most recent quantity contained by the sample.

mostRecentQuantityDateInterval

The date interval for the most recent quantity contained by the sample.

Predicate Key Paths

HKPredicateKeyPathMin

The key path for the sample’s minimum quantity.

HKPredicateKeyPathAverage

The key path for the sample’s average quantity.

HKPredicateKeyPathMax

The key path for the sample’s maximum quantity.

HKPredicateKeyPathMostRecent

The key path for the sample’s most recent quantity.

HKPredicateKeyPathMostRecentStartDate

The key path for the start date of the sample’s most recent quantity.

HKPredicateKeyPathMostRecentEndDate

The key path for the end date of the sample’s most recent quantity.

HKPredicateKeyPathMostRecentDuration

A key path for the duration of the sample’s most recent quantity.

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