我試圖通過代碼來請求授權的範疇中healthkit:參數類型「[HKCategoryType?]」不符合預期型「哈希的」
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?