In the last tutorial we covered reading characteristic data from HealthKit. Characteristic data is read by accessing direct methods on the health store. These queries are simple because items like date of birth and biological sex do not typically change. However, there are many data types stored in Apple Health that do change such as step counts, heart rate, body mass, and so on. For these types of data Apple allows us to create queries so that we can fetch the data we want.
Many of your requests to HealthKit will be done by using a query. Queries allow you to fetch a snapshot of data from the HealthKit store. There are eight different types of queries that you have available to use with HealthKit. This tutorial will cover the HKSampleQuery. We will look at each other type of query in separate posts. [Read more…]