I need to pass a data between two view controllers.here is my code.
for first view controller
-(void)editBotton {
Carttable *second=[[Carttable alloc]init];
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:second];
nav.modalTransitionStyle=UIModalTransitionStyleCrossDissolve;
[self.navigationController pushViewController:second animated:YES];
NSString *temp=titlela.text;//titlela is UILabel
NSLog(@"%@",temp);
self.cart=second;
cart.cnftitle=temp;
}
in my cartable view controller.h
@property(nonatomic,retain)NSString *cnftitle;
and i synthesized too
- (void)viewDidLoad
{
[super viewDidLoad];
NSLog(@"%@",cnftitle);
}
one NSlog prints my text in label where another prints as NULL….
am i missing anything?
You’re assigning the value after the view has loaded.
Move your assignment before the
pushViewController:(as that’s the point where the view is loaded)