Swift programmatically sets segments

I have a snippet of analysis code that checks 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 successfully logging in, I want to send the user to a new session. I cannot do this in the storyboard because I want segue to happen if the conditions are met. Anyway, to programmatically create a segue?

+6
source share
1 answer

You can use:

 performSegueWithIdentifier("yourSegueIdentifier", sender: nil) 

You do not need to "create" segue programmatically, just plug in ViewControllers and create a Segue. Using the performSegueWithIdentifier function, you can manually name your segue if necessary.

+20
source

Source: https://habr.com/ru/post/977151/


All Articles