SWIFT: You should use an unwind segue.
-
First of all, put the following line in your
FirstViewController:@IBAction func prepareForUnwind(segue: UIStoryboardSegue) { }The function actually doesn’t have any code inside it.
- Now, go to your storyboard and create an unwind segue for
LogoutViewControllerby control-dragging from the yellow button to the Exit button. Like this:

-
Select the unwind segue created for
FirstViewController. -
Change the segue identifier:


-
Go to the code of
LogoutViewControllerand just call the unwind segue normally:self.performSegueWithIdentifier("unwindToViewController1", sender: self)Swift 4
self.performSegue(withIdentifier: "unwindToViewController1", sender: self)