我在我的 iOS Swift 应用程序中添加 HealthKit 的代码,但出现错误:
/* Ask for permission to access the health store */
override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)
if HKHealthStore.isHealthDataAvailable(){
healthStore.requestAuthorizationToShareTypes(typesToShare,
readTypes: typesToRead,
completion: {(succeeded: Bool, error: NSError!) in
if succeeded && error == nil{
println("Successfully received authorization")
} else {
if let theError = error{
println("Error occurred = \(theError)")
}
}
})
} else {
println("Health data is not available")
}
}
发生错误 = 错误域 = com.apple.healthkit 代码 = 4“缺少 com.apple.developer.healthkit 权利。” UserInfo=0x7fa748534b00 {NSLocalizedDescription=缺少 com.apple.developer.healthkit 权利。}
如何解决这个问题?