Initializes a new active summary query.
- iOS 9.3+
- Mac Catalyst 13.0+
- watchOS 2.2+
A predicate that filters the activity summaries returned by the query. Pass
nilto receive all activity samples.
A block that is called after the initial results have been gathered. This block takes the following parameters:
A reference to the query calling this block.
An array containing the summaries returned by this query, or
nilif an error occurred.
If an error occurs, this parameter contains an object describing the error; otherwise, it is
A newly initialized activity summary query.
After instantiating the query, call the
execute(_:) method to run it. The queries run on an anonymous background queue. As soon as the query is complete, the results handler block is executed on the same background queue (but not necessarily the same thread). You typically dispatch these results to the main queue to update the user interface.
Activity summary queries can also act as long-running queries. If you assign an update handler before you execute the query, the query continues to monitor the HealthKit store after gathering the initial results. The update handler is called on a background queue every time a matching sample is saved or updated in the HealthKit store. You can cancel this query by calling the store’s