0

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)

        }
    }
bennyty
  • 371
  • 5
  • 18
user2540538
  • 205
  • 3
  • 8

1 Answers1

0

Based off be comments above it sounds like your app is crashing after the login. If that's the case:

Try changing user!=nil to error == nil

UPDATE

Check class permissions

nick9999
  • 601
  • 1
  • 8
  • 22