0

I'm developing a login view. I'm using Parse for the backend. The idea is very regular. If the user has registered already the app lets him in with no additional inconvenience. I put this code in viewDidLoad():

override func viewDidLoad() {

        super.viewDidLoad()

        if PFUser.currentUser() != nil {

            self.performSegueWithIdentifier("login", sender: self)

        }
    }

After the app is compiled, it goes through that block of code but the login segue are not performing. Please let me know your suggestions what's wrong with? Thank you so much in advance!

Aaron Brager
  • 65,323
  • 19
  • 161
  • 287
  • Does the segue exist? Also, what kind of segue are you using? If it's a push segue then you'll need a UINavigationController. – Fogmeister Jan 24 '15 at 13:56
  • Yes, it certainly exists. The type is `show`. –  Jan 24 '15 at 13:59
  • You can't perform a segue in `viewDidLoad()` because the view isn't visible yet. Move to `viewWillAppear()`. See [Perform Segue on ViewDidLoad](http://stackoverflow.com/questions/8221787/perform-segue-on-viewdidload). – Aaron Brager Jan 24 '15 at 14:37

1 Answers1

2

It isn't possible to perform a segue in the viewDidLoad method.

Move it into the viewDidAppearmethod and it will work.

Christian
  • 22,585
  • 9
  • 80
  • 106