开发者

trouble passing variable

开发者 https://www.devze.com 2023-03-18 22:16 出处:网络
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.

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

精彩评论

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