Class

HKCumulativeQuantitySample

A sample that represents a cumulative quantity.

Declaration

@interface HKCumulativeQuantitySample : 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 that accumulates over time, such as step count, active energy burned, or walking distance.

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

Using Cumulative Quantity Samples

Like many HealthKit classes, you should not subclass the HKCumulativeQuantitySample 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 Data

sumQuantity

The sum of all the quantities contained by the sample.

Relationships

Inherits From

See Also

First Steps

Saving Data to HealthKit

Create and share HealthKit samples.

HKDiscreteQuantitySample

A sample that represents a discrete 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.