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

See Also

First Steps

Saving Data to HealthKit

Create and share HealthKit samples.

HKCumulativeQuantitySample

A sample that represents a cumulative quantity.

HKQuantitySample

A sample that represents a quantity, including the value and the units.

HKCategorySample

A sample whose values are selected from a short list of possible values.

HKCorrelation

A sample that groups multiple related samples into a single entry.

Units and Quantities

Objects used to specify a quantity for a given unit (for example, 175 lbs), and to convert between units (79.4 kg).

Metadata Keys

Constants used to add metadata to objects stored in HealthKit.