I am programming a small social network app for a community in Swift.
I got the error: fatal error: unexpectedly found nil while unwrapping an Optional value (lldb)
when I try to change views with self.presentViewController(FeedViewController(), animated: true, completion: nil)
. This line of code only executes if the user is allowed access to the second page.
Here is the full code:
@IBAction func loginButtonPressed(sender: AnyObject) {
if passwordTextField.text == "" || nameTextField.text == "" {
Global.showAlert("Erreur", message:"Nom d'utilisateur ou mot de passe invalide!", view:self)
} else {
PFUser.logInWithUsernameInBackground(nameTextField.text, password:passwordTextField.text) {
(user: PFUser!, error: NSError!) -> Void in
if user != nil {
} else {
// The login failed. Check error to see why.
//var err = error.userInfo["error"] as NSString
Global.showAlert("Erreur", message:"Nom d'utilisateur ou mot de passe invalide!", view:self)
}
}