Class

HKCumulativeQuantitySample

A sample that represents a cumulative quantity.

Declaration

class 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 init(type:quantity:start:end:metadata:).

Topics

Accessing Calculated Data

var sumQuantity: HKQuantity

The sum of all the quantities contained by the sample.

Relationships

Inherits From

Conforms To

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