我正在尝试throws使用完成处理程序向我的现有函数添加一个但我不断收到警告说no calls throwing functions occur within try expression.在我抛出错误的部分,我得到一个错误说
从抛出'()throw - > Void'类型的函数到非投掷函数类型的无效转换.
enum LoginError: ErrorType {
case Invalid_Credentials
case Unable_To_Access_Login
case User_Not_Found
}
@IBAction func loginPressed(sender: AnyObject) {
do{
try self.login3(dict, completion: { (result) -> Void in
if (result == true)
{
self.performSegueWithIdentifier("loginSegue", sender: nil)
}
})
}
catch LoginError.User_Not_Found
{
//deal with it
}
catch LoginError.Unable_To_Access_Login
{
//deal with it
}
catch LoginError.Invalid_Credentials
{
//deal with it
}
catch
{
print("i dunno")
}
}
func …Run Code Online (Sandbox Code Playgroud)