I have a scenario where I need to retrieve multiple sets of data from HealthKit -- body temperature, weight, and blood pressure. I need all 3 before I can continue processin
You're going to want to use GCD dispatch groups.
First, set up a global variable for the main thread
var GlobalMainQueue: dispatch_queue_t {
return dispatch_get_main_queue()
}
Next, create the dispatch group:
let queryGroup = dispatch_group_create()
Right before your queries execute, call:
dispatch_group_enter(queryGroup)
After your query executes, call:
dispatch_group_leave(queryGroup)
Then, handle your completion code:
dispatch_group_notify(queryGroup, GlobalMainQueue) {
// completion code here
}