I do not know how to do the vice-versa part but use this for transferring data to another view controller: (I am going to pretend that I want to pass a string named "hello" to the second view controller)
(I will now call the First View Controller FirstVC, and I'll call the second view controller SecondVC)
In storybord, click on segue and in the utilities section open Attributes and look for the identifier box
, and enter "Segue"
2.In the second view controller.h file, declare a property and synthesize it(in both FirstViewController, and Second):
@property (nonatomic, retain) NSString *hello;
3.In the FirstViewCOntroller add this code:
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender identifiers:(NSArray *)identifiers {
if ([segue.identifier isEqualToString:@"Segue"]) {
SecondViewController *secondVC = [segue destinationViewController];
secondVC.hello = self.hello;
}
}