【发布时间】:2019-07-13 18:18:32
【问题描述】:
我的应用中有这段代码:
func saveContact2(contact: String) throws {
let contactStore = CNContactStore()
contactStore.requestAccess(for: .contacts, completionHandler: {(granted, error) in
if granted && error == nil {
//...
} else {
if !granted {
throw contactErrors.contactAccessNotGranted(["Error","Access to Contacts is not granted."])
}
}
})
}
我想将所有在调用函数关闭时引发的错误都抛出。
编译器显示错误:
从'(_, _) throws -> ()' 类型的抛出函数到非抛出函数类型'(Bool, Error?) -> Void'的无效转换
谁能帮我正确的语法?
【问题讨论】: