尝试构建需要健康数据的独立手表应用程序。但是,healthStore.requestAuthorization不在监视屏幕上显示任何内容。
@IBAction func showHeartrate() {
if HKHealthStore.isHealthDataAvailable(){
let healthStore = HKHealthStore()
let types = Set([HKObjectType.quantityType(forIdentifier: .heartRate)!
])
healthStore.requestAuthorization(toShare: types, read: types) { (success, error) -> Void in
if !success{
print("error occured")
}
if success{
print("authrorized")
}
}
}
}