当我从Xcode 6转换为Xcode 7时,读取和写入HK存储时,在以下行中出现错误"表达式类型不明确,没有更多上下文":'let healthKitTypesToRead=Set(arrayLiteral:[]和'let heahealthKittypesToWrite=Set(arryLiteral:["
// 1. Set the types you want to read from HK Store
let healthKitTypesToRead = Set(arrayLiteral:[
HKObjectType.quantityTypeForIdentifier(HKQuantityTypeIdentifierHeartRate),
HKObjectType.quantityTypeForIdentifier(HKQuantityTypeIdentifierActiveEnergyBurned),
])
// 2. Set the types you want to write to HK Store
let healthKitTypesToWrite = Set(arrayLiteral:[
HKObjectType.quantityTypeForIdentifier(HKQuantityTypeIdentifierActiveEnergyBurned),
])
我如何修复这个红色警报错误,或者写替代代码来读/写到香港商店?
我刚刚解决了。'QuantityTypeForIdentifier需要更改为characteristicTypeForIdentifier',以及其他一些格式更改:
{
// 1. Set the types you want to read from HK Store
let healthKitTypesToRead = Set(arrayLiteral:
HKObjectType.characteristicTypeForIdentifier(HKQuantityTypeIdentifierHeartRate)!,
HKObjectType.characteristicTypeForIdentifier(HKQuantityTypeIdentifierActiveEnergyBurned)!
)
// 2. Set the types you want to write to HK Store
let healthKitTypesToWrite = Set(arrayLiteral:
HKObjectType.characteristicTypeForIdentifier(HKQuantityTypeIdentifierActiveEnergyBurned)!
)