它说:
Cannot invoke 'requestAuthorizationToShareTypes' with an argument list of type (HKQuantityType, readTypes: HKCharacteristicType, completion: (Bool, NSError!) -> Void)
请帮忙
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
if HKHealthStore.isHealthDataAvailable() {
let healthStore = HKHealthStore()
healthStore.requestAuthorizationToShareTypes(HKSampleType.quantityTypeForIdentifier(HKQuantityTypeIdentifierStepCount)!, readTypes: (HKCharacteristicType.characteristicTypeForIdentifier(HKCharacteristicTypeIdentifierBiologicalSex))! , completion:{
(success:Bool,error:NSError!) -> Void in
if !success{
print("error")
}
})
}
}
最佳答案
requestAuthorizationForTypes
方法需要Sets HKObjectType
。试试这个:
let shareTypes : Set = [HKSampleType.quantityTypeForIdentifier(HKQuantityTypeIdentifierStepCount)!]
let readTypes : Set = [HKCharacteristicType.characteristicTypeForIdentifier(HKCharacteristicTypeIdentifierBiologicalSex)!]
healthStore.requestAuthorizationToShareTypes(shareTypes, readTypes:readTypes, completion: { (success, error) -> Void in
if !success{
print("error")
}
})
关于ios - 无法使用类型的参数列表调用 'requestAuthorizationToShareTypes',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31836412/