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
在調試器中設置異常斷點以查看確切的錯誤消息。 –
你是否在顯示警報時在主線程中?我懷疑你不是.. –