开发者

trouble passing variable

HI have a little problem, I want to pass a simple variable between 2 viewcontrollers, I try in this way but I get a null variable.

Controller1.m

SecondaVista *secondaVista = [[SecondaVista alloc] init] ;
[self.navigationController pushViewController:secondaVista animated:YES];
secondaVista.titolo = @"Ciao";

Controller2.h

NSString *titolo;
@propert开发者_如何学JAVAy (nonatomic,retain) NSString *titolo;

Controller2.m

NSLog(@"%@",self.titolo);

where is the mistake?


try setting the variable before pushing the view.

SecondaVista *secondaVista = [[SecondaVista alloc] init] ;
secondaVista.titolo = @"Ciao"; 
[self.navigationController pushViewController:secondaVista animated:YES];

Where are you logging the variable? I mean in viewDidLoad or viewWillAppear where?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜