As the name suggests, an HKStatisticsCollection object manages a collection of statistics. Each statistics object represents the data calculated over a separate time interval.


For more information on statistics objects, see HKStatistics. For more information on calculating statistics over consecutive time intervals, see HKStatisticsCollectionQuery.


Accessing Statistics Collections

func statistics()

Returns an array of statistics objects representing the populated time intervals covered by the statistics collection query.

func statistics(for: Date)

Returns the statistics object for the time interval that contains the provided date.

func enumerateStatistics(from: Date, to: Date, with: (HKStatistics, UnsafeMutablePointer<ObjCBool>) -> Void)

Enumerates the statistics objects for all the time intervals from the start date until the end date.

Getting Information About Statistics Collections

func sources()

Returns a set containing all the sources that had samples matched by the statistics collection query.


Inherits From

Conforms To