如果Swift功能,则知道是否存在错误

时间:2017-04-11 16:46:07

标签: swift swift3

有时候这个函数有这个结构:

func prueba(................, error: Error?){
    //Code here

    //How I can validate if error really exist?
}

如果我使用if制作error!=nil,则始终不是真的,但错误不存在。

1 个答案:

答案 0 :(得分:3)

对于实际具有可选<button onclick="myApp.showAlert()">Alert not working</button> 参数的函数,您可以执行以下操作:

Error