Whenever I will make the screen pass with login and password my application to with the error below:
fatal error: unexpectedly found nil while unwrapping an Optional value
function signature specialization of Swift (_ fatalErrorMessage (Swift.StaticString, Swift.StaticString, Swift.StaticString, Swift.UInt) -> ()) (closure # 2)
I have already checked the returns of the functions, if it had some wrong Outlet, it's all right. This error occurred also in a simple screen transition, with no content, just drag and pull, I do not know what it can be. It prints the user and the id normally, but at the time of going to the other screen gives error. Here is the part of my code where the application for:
@IBAction func logar(sender: AnyObject) {
self.myProgress.hidden = false
self.myProgress.startAnimating()
let parametros: NSDictionary = ["email":emailField.text!, "senha":senhaField.text!]
controller.getLogin(parametros, handlerUser: {(usuario) -> () in
self.usuarioAtual = usuario
if self.usuarioAtual.msgError == "" {
self.emailField.text = ""
self.senhaField.text = ""
self.myProgress.hidden = true
self.myProgress.stopAnimating()
let storyBoard = UIStoryboard(name: "Main", bundle: nil)
let accessNavigation = storyBoard.instantiateViewControllerWithIdentifier("AccessViewController")
LoginViewController.sharedInstance.usuarioAtual = self.usuarioAtual
self.navigationController?.pushViewController(accessNavigation, animated: true)
} else {
Alerta(controller: self).erro("Desculpe!", message: self.usuarioAtual.msgError)
print(self.usuarioAtual.msgError)
self.myProgress.hidden = true
self.myProgress.stopAnimating()
}
})
}
I think that what Xcode is saying is null is navigationController
, but I do not know why, I use that same structure to pass the other screens and they work, even yesterday it was working normally, without changes this error appeared.