0
我试图在密码匹配时显示警报消息。一切都运行得非常好:警报 - libC++ abi.dylib:以NSException类型的未捕获异常终止
1)Web服务调用,并返回密码
2)流量进入,如果条件涉及的比赛中密码
if(userPasswd == sysPasswd)
{
displayAlert(userMessage: "Welcome! You have been authenticated")
return
}
的displayAlert函数被调用成功:
func displayAlert(userMessage: String)
{
// create the alert
let myAlert = UIAlertController(title: "Alert", message: userMessage, preferredStyle: UIAlertControllerStyle.alert)
// add an action (button)
myAlert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.default, handler: nil))
// show the alert
self.present(myAlert, animated: true, completion: nil)
}
当执行的最后一条语句它给这个错误
libc++abi.dylib: terminating with uncaught exception of type NSException
这是怎么发生的?我是斯威夫特的初学者,仍然在学习绳索。没有黄色标志等。
当网络方法返回时,你确定'self'存在吗? – the4kman
在调试器中设置异常断点以查看确切的错误消息。 –
你是否在显示警报时在主线程中?我怀疑你不是.. –