Helo all,
I am moving from one view controller to another using below code.
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle: nil];
UIViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"RoloBusinessCard"];
[self.navigationController pushViewController:vc animated:YES];
Now i want to pass some data from one view controller to another like some variable.I have got this code to do this task but i am not making instance of another view controller.I am starting another view controller using storyboard.
SecondViewController *secondViewController = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];
secondViewController.str1 = str;
[self.navigationController pushViewController:secondViewController animated:YES];
Please tell me how can i pass data between view controllers in my way?
Solution does not work
decalre NSString
in .h
file.
@property (nonatomic, strong) NSString *UserId;
Synthesize in .m file
@synthesize UserId;
Code for navigation
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle: nil];
UIViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"RoloBusinessCard"];
vc.UserId=@"abc";
[self.navigationController pushViewController:vc animated:YES];
But vc.UserId
does not recognized.