gpt4 book ai didi

ios - 无法使用类型的参数列表调用 'requestAuthorizationToShareTypes'

转载 作者:行者123 更新时间:2023-11-29 01:46:42 26 4
gpt4 key购买 nike

它说:

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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com