Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

CMT

macrumors regular
Original poster
Aug 24, 2009
104
10
What is the best option for creating nav controllers inside a tab bar controller:

1.Keep the tab as ivar:
Code:
@interface AppDelegate ... {
    UITabBarController *tabController;
    ... window;
}
...
@implementation AppDelegate

-(void)applicationDidFinishLaunching {
   tabController = [[UITabBarController alloc] init];

   // Create nav controllers, put them on tabController and release them

   [window addSubview:tabController.view];
   [window makeKeyAndVisible];
}

-(void)dealloc {
   [tabController release];
   [super dealloc];
}

2.Keep everything as ivars:
Code:
@interface AppDelegate ... {
    UITabBarController *tabController;
    UINavController *firstNavController, secondNavController;
    ... window;
}
...
@implementation AppDelegate

-(void)applicationDidFinishLaunching {
   tabController = [[UITabBarController alloc] init];

   // 'alloc] init];' nav controller

   // add them to tab controller

   [window addSubview:tabController.view];
   [window makeKeyAndVisible];
}

-(void)dealloc {
   [firstNavController release];
   [secondNavController release];
   [tabController release];
   [super dealloc];
}

Are there any advantages on keeping everything as ivars? Or the top controller only is enough, so it can be accessed later? Or maybe, I'm completely wrong and there is no need to keep an view controller ivar? :p

Thanks!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.