I’m currently fixing the memory leaks that cause too many crashes to my iPhone app…
In the appDelegate, I use the following code to init the tabbarcontroller. Is that a good way to do so, especially the “homeNavigationController.tabBarItem init” part ? (tabBarController is a property and is released within the dealloc method).
NSMutableArray *localControllersArray = [[NSMutableArray alloc] initWithCapacity:4];
tabBarController = [[UITabBarController alloc] init];
// HomeTab view
HomeTabViewController *home = [[HomeTabViewController alloc] initWithNibName:@"HomeTabViewController" bundle:nil];
UINavigationController *homeNavigationController = [[UINavigationController alloc] initWithRootViewController:home];
[homeNavigationController.tabBarItem initWithTitle:NSLocalizedString(@"home", @"home") image:[UIImage imageNamed:@"home.png"] tag:1];
[localControllersArray addObject:homeNavigationController];
[homeNavigationController release];
[home release];
// My 3 others controllers
...
// End 3 other controllers
tabBarController.viewControllers = localControllersArray;
tabBarController.selectedIndex = 0;
[self.window addSubview:tabBarController.view];
[localControllersArray release];
[tabBarController setDelegate:self];
[self.window makeKeyAndVisible];
This
is a leak. You should change it to: