4

I have two controllers in the storyboard, and there is a segue to switch between these.

Passing data from the first controller to the second one is pretty straightforward by implementing prepareForSegue, and set the properties of the second controller using segue.destinationViewController.

I should pass back data to the from the second controller to the previous one also. I googled, but I have not found any simple, but working code to demonstrate it.

Would you be so kind give me a simple sample about the best way to do it?

Victor Zakharov
  • 25,801
  • 18
  • 85
  • 151
James Douglas
  • 736
  • 1
  • 11
  • 20

1 Answers1

0

See: Xcode 4.5 Storyboard 'Exit'

You need a method like

-(IBAction)returned:(UIStoryboardSegue *)segue;

in the UIViewController you want to return (the 'first controller'). In the storyboard you select the second controller and connect your button to the green exit icon in the bottom of this controller with this method.

In the method you have access to the second controller.

Community
  • 1
  • 1
Obenland
  • 856
  • 16
  • 28
  • fair enough I've done that and it works fine. However -(IBAction)returned:(UIStoryboardSegue *)segue; is located in controller1. Now how would I be able to pass the data from controller 2 using unwind. – James Douglas Feb 25 '13 at 19:17