Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

On storyboards, views and passing data along

In my Xcode 4.2 storyboard, i have 2 UIViewControllers, This one time and In band camp

  • In This one time, i have a UIButton with "silly name" on it
  • In In band camp, i have a UILabel with "label" on it

Considering that we're dealing with 2 separate classes AND we're in Xcode 4.2 using storyboards (where transition between views is setup via a segue) how can i pass "silly name" from view controller This one time to the label in view controller In band camp?"

enter image description here

like image 226
James Raitsev Avatar asked Oct 21 '11 22:10

James Raitsev


1 Answers

  1. Set the identifier of segue in storyboard to "AwesomeSegue"
  2. Implement prepareForSegue method
  3. Inside the method, check if identifier of segue matches "AwesomeSegue" - if yes, use the destinationViewControllerObject

    - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
        if ([segue.identifier isEqualToString:@"AwesomeSegue"]) {
            InBandCampViewController *ibcVC = [segue destinationViewController];
            ibcVC.yourData = self.someStuff;
        }
    }
    
like image 171
LordTwaroog Avatar answered Oct 10 '22 02:10

LordTwaroog