Query health and fitness data.
Use queries to read sample data from the HealthKit store. Queries can also be used to list all the sources for a particular type of data, or to do statistical calculations. For example, statistical queries can calculate the minimum and maximum heartrate for a given week, or the total step count for a given day.
You run a query by calling the HealthKit store’s
execute method. A snapshot of the current results are asynchronously returned to the query’s results handler. Long-running queries continue to monitor the HealthKit store, and return any relevant changes to the query’s update handler. To return sorted or filtered results, give the query a sort descriptor or predicate.