This is the copy of source code one could see on What's new in Health Kit Session:
// predicate for sleep samples
let remSleepStagePredicate = HKCategoryValueSleepAnalysis.predicateForSamples(.equalTo, value: .asleepREM)
// create query with the designated sleepStagePredicate
let queryPredicate = HKSamplePredicate.sample(type: HKCategoryType(.sleepAnalysis), predicate: remSleepStagePredicate)
// Sleep Query
let sleepQuery = HKSampleQueryDescriptor(predicates: [queryPredicate], sortDescriptors: [])
// Run the query
let sleepSamples = try async sleepQuery.result(for: healthStore)
I tried to take a snaphot of the session itself, but for some reason I could not submit it with the file attached so I provided the code above.
I am wondering that shouldn't it be try await, not try async on the last line of the source code?
so the last line should be the code below:
let sleepSamples = try await sleepQuery.result(for: healthStore)
Am I mistaken, or is it a human error?
Topic:
App & System Services
SubTopic:
Health & Fitness
Tags:
Health and Fitness
HealthKit
wwdc2022-10005