Again, .NET developer that's new to iOS/Mac-type development.
I'm attempting to use a TabBar delegate method "didSelectViewController" to intercept a tab change and set a property on the view controller when a specific tab is set. Everything is "working" except the property's value appears to have lost persistence by the time I arrive at the view controller's "viewDidLoad" method.
I need to back up a little bit and figure out what the "best practice" is when doing something like this. Should I be using a global variable instead of trying to set a property of the view controller?
Or... am I doing something wrong in the declaration of the property? Here's what I did on the view controller header:
Then the .m file:
The delegate:
With this, by the time I grab the value of "listType" in the "viewDidLoad" method of EntityListViewController, it's empty.
Just need a point in the right direction. Thanks.
I'm attempting to use a TabBar delegate method "didSelectViewController" to intercept a tab change and set a property on the view controller when a specific tab is set. Everything is "working" except the property's value appears to have lost persistence by the time I arrive at the view controller's "viewDidLoad" method.
I need to back up a little bit and figure out what the "best practice" is when doing something like this. Should I be using a global variable instead of trying to set a property of the view controller?
Or... am I doing something wrong in the declaration of the property? Here's what I did on the view controller header:
Code:
...
@interface EntityListViewController: UIViewController {
@public
NSString *listType;
NSNumber *someID;
}
@property (retain) NSString *listType;
@property (nonatomic, retain) NSNumber *someID;
...
Then the .m file:
Code:
...
@synthesize listType;
@synthesize someID;
...
The delegate:
Code:
// Optional UITabBarControllerDelegate method.
- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController {
if (viewController.tabBarItem.tag == 2) {
// Set a property of the currently selected view
((EntityListViewController *)viewController).listType = @"Testing";
}
}
With this, by the time I grab the value of "listType" in the "viewDidLoad" method of EntityListViewController, it's empty.
Just need a point in the right direction. Thanks.