I blocked on an issue since 1 hours about Setter/Getter on objective-c
I implement the code below to do some action depending on user choose.
In my view controller interface :
@property NSString* view_test;
In my implementation
@synthesize view_test;
The user acces to an other view after a click on a button with this method
- (IBAction)PPBarButtonClick:(id)sender {
[self setView_test:@"test"];
NSLog(@"view_test %@", [self view_test]); // Print test
}
And after my viewDidLoad method:
- (void)viewDidLoad
{
[super viewDidLoad];
NSLog(@"view_test %@", [self view_test]); // print always null
if ([[self view_test] isEqualToString:(@"test")]) {
//some action
} else {
// other action
}
}
And my trace
2016-04-04 07:44:43.266 MyApp[19926:675795] view_test (null)
2016-04-04 07:45:11.817 MyApp[19926:675795] view_test test
2016-04-04 07:45:11.925 MyApp[19926:675795] view_test (null)
I don't understand why after setting "test" to view_test, the print retu (null)? I'm lost
Thanks
