The HKAnchoredObjectQuery provides a useful way to keep tabs on what has changed for a particular sample type. It provides us with both the ability to receive a snapshot of data, and then on subsequent calls, a snapshot of what has changed. Alternatively you can create the initial snapshot of samples, and then continuously monitor as a long-running query which notifies you each time a new sample is added or when a sample is deleted.
For this tutorial we will continue on from an earlier tutorial, and add more functions that will allow us to test the HKAnchoredObjectQuery class. Go ahead and download the latest version of the project and open it in Xcode. [Read more…]