Contents

init(quantityType:predicate:quantityHandler:)

Creates a new query for a series of the specified quantity type.

Declaration

init(quantityType: HKQuantityType, predicate: NSPredicate?, quantityHandler: @escaping  @Sendable (HKQuantitySeriesSampleQuery, HKQuantity?, DateInterval?, HKQuantitySample?, Bool, (any Error)?) -> Void)

Parameters

  • quantityType:

    The quantity type.

  • predicate:

    A predicate used to filter the results. To query for all the quantity objects for a specific Hkquantitysample, see Predicateforobject(with:).

  • quantityHandler:

    A handler called by the query with the results. The query calls the block multiple times until either the done parameter is True, or you call the HealthKit store’s Stop(_:) method. The handler takes the following arguments:

    query

    The query that generated the results.

    quantity

    The next quantity in the series.

    dateInterval

    The quantity’s date interval.

    quantitySample

    The quantity sample that owns the series. This parameter is set to nil unless Includesample is true.

    done

    A Boolean value that indicates whether you have reached the end of the series.

    error

    If an error occurs, this parameter describes the error. Otherwise, it is set to nil.

Discussion

HealthKit returns quantities in ascending order, based on their start date.

See Also

Creating a Series Query