【发布时间】:2016-09-23 17:54:29
【问题描述】:
我正在尝试使用代码为 healthkit 中的类别请求授权:
let healthKitStore: HKHealthStore = HKHealthStore()
let healthKitTypesToWrite = Set(arrayLiteral:[
HKObjectType.categoryType(forIdentifier: HKCategoryTypeIdentifierMindfulSession)
])
healthKitStore.requestAuthorizationToShareTypes(healthKitTypesToWrite, readTypes: healthKitTypesToRead) { (success, error) -> Void in
if( completion != nil )
{
completion(success:success,error:error)
}
}
来自https://www.raywenderlich.com/86336/ios-8-healthkit-swift-getting-started。
但当我这样做时,我得到:
参数类型“[HKCategoryType?]”不符合预期类型 '可哈希'
我如何在 Healthkit 中保存一个类别?一般来说,是否有专门针对 HKCategoryType 和 HKCategoryTypeIdentifierMindfulSession 的教程?
【问题讨论】: