1
以下函數在Xcode 7.3和Swift 2中工作* *,在遷移到Xcode 8和Swift 3.0後出現以下錯誤當我嘗試編譯時Xcode Healthkit授權功能錯誤遷移到Xcode 8和Swift 3.0時
cannot call value of non-function type
((Bool, _ error:NSError?) -> Void)!
func authorizeHealthKit(_ completion: ((_ success:Bool, _ error:NSError?) -> Void)!) {
healthKitStore = HKHealthStore()
let typesSet:Set<HKSampleType> = [
HKQuantityType.quantityType(forIdentifier: HKQuantityTypeIdentifier.bodyTemperature)!,
HKQuantityType.quantityType(forIdentifier: HKQuantityTypeIdentifier.respiratoryRate)!,
HKQuantityType.quantityType(forIdentifier: HKQuantityTypeIdentifier.bloodPressureSystolic)!,
HKQuantityType.quantityType(forIdentifier: HKQuantityTypeIdentifier.bloodPressureDiastolic)!,
HKQuantityType.quantityType(forIdentifier: HKQuantityTypeIdentifier.bodyMass)!,
HKQuantityType.quantityType(forIdentifier: HKQuantityTypeIdentifier.heartRate)!,
HKQuantityType.quantityType(forIdentifier: HKQuantityTypeIdentifier.oxygenSaturation)!]
healthKitStore?.requestAuthorization(toShare: typesSet, read: typesSet, completion: { (boolVal, error) in
completion(success: boolVal, error: error) //<-- compile error here
})
}
[如何使用Markdown或HTML格式化我的帖子](http://stackoverflow.com/help/formatting) – buhtz