Quote:
Originally Posted by raven
This is probably more a conceptual issues so experienced insight is welcome.
Code:
localWindow = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window = localWindow;
[localWindow release];
/* Now the following code crashes
localTBC = [[UITabBarController alloc] init];
tabBarController = localTBC;
[localTBC release];
*/
tabBarController = [[UITabBarController alloc] init]; //this works great
***
@property (nonatomic, retain) UIWindow *window;
@property (nonatomic, retain) UITabBarController *tabBarController;
***
Why does it crash when I use the commented lines for tabBarController for the following line.
tabBarController.viewControllers = theVCArray;
It crash as tabBarController has already been released in the commented code case.
I assume the retain count will be 2 due to the assign and retain on tabBarController ivar as it will be for window ivar. Why is it okay with window but not with tabBarController ?
|
It's crashing at that line because the "tabBarController" isn't pointing to anything valid, as you've released the instance you had allocated.
Code:
tabBarController = localTBC;
should be this:
Code:
self.tabBarController = localTBC;