Transfer data using Unwind Segues in iOS Storyboard.

Unwind segue introduced in 2012 with iOS 6, Unwind  means undone after winding, Unwind Segue gives you a way to unwind the navigation stack and specify a destination to go back. Also, you can transfer the data from one viewController to otherController. An Unwind segue transition to an existing view Controller in your navigation hierarchy,

In this post, How to create unwind segues in storyboard and how to transfer data between two viewController, Follow the below steps.

Step 1 : Create new project Xcode > File > New > Project > unwiredSegue-Demo.

Step 2 : Create two ViewController in this project Name as : FirstViewController and SecondViewController.

Step 3 : In your FirstViewController make an action of unwind segue. write below code :
@IBAction func unwindToViewControllerNameHere(segue: UIStoryboardSegue){  
          let viewC :SecondViewController = segue.sourceViewController as! SecondViewController
          self.lblDetails.text = viewC.txtDetails.text
Step 4 :  You also take one label to display data comes from SecondViewControllerand and button for push SecondViewController. Join the lblDetails with FirstViewController  with IBOutlet. and Button to push SecondViewController.

Step 5 : In your SecondViewController , Take one textField to textData and Button name as : UnWired Segue Button ,

Step 6 :  Click on your UnWired Segue Button and action connect to exist icon, See The exist icon for a scene is the orange on the right.

See full image for to connect Unwind segue:

See the demo project to transfer data from SecondView controller to firstViewController, Download the below demo project:


Transfer data using Unwind Segues in iOS Storyboard. Transfer data using Unwind Segues in iOS Storyboard. Reviewed by Kirit Modi on 10:13:00 Rating: 5

No comments:

Powered by Blogger.