For todays tutorial we will look at reading characteristic data from HealthKit. This is one of several ways in which we can read data, with the other ways being queries and long-running queries. We will investigate queries and long-running queries at another time.
Direct method calls can be used to the HKHealthStore to read characteristic data. These items stored in HealthKit do not require a query to be made. These are characteristic types of data such as sex, date of birth, and blood type, to name a few. The reason for this is that these types of data do not change over time. For example, your birthday remains constant.
You can access characteristic data directly through the health store. In a previous tutorial we covered how to setup Apple HealthKit. We will continue on from this project, which you can download here.
In that previous tutorial we requested permissions for stepCount and biologicalSex. Out of these two, biologicalSex is the only one which is characteristic data. We will look at how we can request this data from Apple HealthKit. [Read more…]