【发布时间】:2020-12-29 15:58:03
【问题描述】:
func reuqestConnection(){
var permReq: Set? = [HKObjectType.quantityType(forIdentifier: .heartRateVariabilitySDNN),
HKObjectType.quantityType(forIdentifier: .restingHeartRate),
HKObjectType.quantityType(forIdentifier: .heartRate)]
if let healthStore = healthStore{
healthStore.requestAuthorization(toShare: nil, read: permReq){ (success, error) in
if(!success){
//redirect to error view to try again.
}
}
}
}//func ends
这就是代码,除了定义 HKHealthStore 的 init 函数之外没有别的了。我得到的错误是在请求授权时
Cannot convert value of type 'Set<HKQuantityType?>?' to expected argument type 'Set<HKObjectType>?'
我不确定这意味着什么,因为我之前没有收到此错误。我应该在这里做什么?
【问题讨论】:
-
您正在用一种类型的项目 (Set
?) 填充数组,而预期的项目是另一个 (Set)。