Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swift programmatically set segues

I have a piece of parse code that checks to see if a user is logged in:

PFUser.logInWithUsernameInBackground("myname", password:"mypass") {
  (user: PFUser!, error: NSError!) -> Void in
  if user != nil {
    // Do stuff after successful login.
  } else {
    // The login failed. Check error to see why.
  }
}

After the successful login I want to send the user to a new segue. I can't do this in the storyboard because I only want the segue to occur if the conditions are met. Is there anyway to create a segue programmatically?

like image 584
Jim McDermott Avatar asked Oct 23 '14 19:10

Jim McDermott


1 Answers

You can use:

performSegueWithIdentifier("yourSegueIdentifier", sender: nil)

You dont need to "create" a segue programmatically, just connect your ViewControllers and create a Segue. With performSegueWithIdentifier you can call your segue manually if needed.

like image 80
derdida Avatar answered Nov 15 '22 07:11

derdida