Created
October 3, 2012 07:12
-
-
Save ryanhanwu/3825531 to your computer and use it in GitHub Desktop.
StoryBoard pass value between viewcontrollers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| - (IBAction)passValueButton:(id)sender { //An action method | |
| [self performSegueWithIdentifier:@"gotoView2" sender:self]; | |
| } | |
| #pragma mark handle segue | |
| - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { | |
| if ([[segue identifier] isEqualToString:@"gotoView2"]) { | |
| User *user = [[User alloc] init]; | |
| user.name = "Ryan"; | |
| user.age = "26"; | |
| ViewController2* viewCtrl2 = segue.destinationViewController; | |
| //the destination is View 2 | |
| viewCtrl2.user = user; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| - (void)viewDidLoad | |
| { | |
| [super viewDidLoad]; | |
| NSLog(@"Name : %@", self.user.name); | |
| NSLog(@"Age : %@", self.user.age); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment