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
doneparameter is True, or you call the HealthKit store’s Stop(_:) method. The handler takes the following arguments:queryThe query that generated the results.
quantityThe next quantity in the series.
dateIntervalThe quantity’s date interval.
quantitySampleThe quantity sample that owns the series. This parameter is set to
nilunless Includesample is true.doneA Boolean value that indicates whether you have reached the end of the series.
errorIf 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.