Skip to content

Instantly share code, notes, and snippets.

@ryanhanwu
Created October 3, 2012 07:03
Show Gist options
  • Save ryanhanwu/3825488 to your computer and use it in GitHub Desktop.
Save ryanhanwu/3825488 to your computer and use it in GitHub Desktop.
Nib Way pass value
- (IBAction)passValueButton:(id)sender { //An action method
{
User *user = [[User alloc] init];
user.name = "Ryan";
user.age = "26";
//get the instance of ViewController2
ViewController2 *viewCtrl2 = [[SecondViewController alloc]
initWithNibName:@"ViewController2" bundle:[NSBundle mainBundle]];
viewCtrl2.user = user;
[self presentModalViewController:viewCtrl2 animated:YES];//Go to view 2
}
- (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