Contents

enumerateStatistics(from:to:with:)

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

Declaration

func enumerateStatistics(from startDate: Date, to endDate: Date, with block: @escaping (HKStatistics, UnsafeMutablePointer<ObjCBool>) -> Void)

Parameters

  • startDate:

    The start date for the calculation. The initial statistics come from the time interval that contains the start date.

  • endDate:

    The end date for the calculation. The final statistics come from the time interval that contains the end date.

  • block:

    A block that is called once for each time interval. This method passes the following parameters to the block:

    result

    The Hkstatistics object containing the statistical data for this time interval.

    stop

    A reference to a Boolean value. The block can set the value to True to stop further processing of the collection. The stop argument is an out-only argument. Only set this Boolean to True within the block.

Discussion

This method enumerates the statistics in chronological order. It calls the block once for each time interval between the start and end dates. If there are no samples for a particular time interval, the corresponding statistic object has a nil-valued quantity.

See Also

Accessing Statistics Collections