init(electrocardiogram:dataHandler:)
Creates a new electrocardiogram query object.
Declaration
init(electrocardiogram: HKElectrocardiogram, dataHandler: @escaping (HKElectrocardiogramQuery, HKElectrocardiogram.VoltageMeasurement?, Bool, (any Error)?) -> Void)Parameters
- electrocardiogram:
The electrocardiogram sample whose voltages you want to access.
- dataHandler:
A block that the query calls repeatedly to return the voltage data. The handler takes the following parameters:
queryThe query that returned the results.
voltageMeasurementA voltage measurement.
doneIndicates whether the query has additional voltage measurements to send.
errorIf an error occurred, this parameter contains information about the error. Otherwise it’s
nil.
Discussion
When you run the query, it calls the data handler once for each voltage measurement, passing the voltage data. On the last voltage measurement, it sets the done parameter to true. If an error occurs, it stops collecting voltage data and calls the data handler; it sets the voltageMeasurement parameter to nil, and passes in an NSError object that describes the error.