我更新到Swift 2和Xcode 7并运行迁移工具。然后我得到了很多错误。一个我卡在本无法调用非函数类型的值'((成功:布尔,错误:NSError?)抛出 - >无效)?)
func authorizeHealthKit(completion: ((success:Bool, error:NSError?) throws -> Void)?)
{
// 1. Set the types you want to read from HK Store
let healthKitTypesToRead = (array:[
HKObjectType.quantityTypeForIdentifier(HKQuantityTypeIdentifierStepCount)
])
// 2. Set the types you want to write to HK Store
let healthKitTypesToWrite = (array:[
HKObjectType.quantityTypeForIdentifier(HKQuantityTypeIdentifierStepCount)
])
// 3. If the store is not available (for instance, iPad) return an error and don't go on.
if !HKHealthStore.isHealthDataAvailable()
{
var error = NSError.self
if(completion != nil)
{
completion(success:false, error:&error)
}
return;
}
// 4. Request HealthKit authorization
healthKitStore.requestAuthorizationToShareTypes(healthKitTypesToWrite as Set<NSObject>, readTypes: healthKitTypesToRead as Set<NSObject>) { (success, error) -> Void in
if(completion != nil)
{
completion(success:success,error:error)
}
}
}
的错误是在完成(成功:虚假,错误&错误)
有什么想法?
是的,修复了第一个错误,但随后它引入了一个新的错误。 '无法将类型'inout NSError.Type'的值转换为期望的参数类型'NSError?' – mosaic6
我建议你分享错误是什么。 – Rob
Thanks @Rob。删除封闭工程中的错误。我不是100%的模式。我正在接管一个项目,这是我正在与之合作的项目。留意我的用户名我会有更多的问题.... – mosaic6