I am curious if there is a good reason I should / should not be using @synthesize for the tabBarController below, or does it not matter?
@implementation ScramAppDelegate
@synthesize window;
@synthesize tabBarController;
-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[self setTabBarController:[[UITabBarController alloc] init]];
[window addSubview:[tabBarController view]];
[window makeKeyAndVisible];
return YES;
}
-(void)dealloc {
[tabBarController release];
[self setTabBarController: nil];
[window release];
[super dealloc];
}
OR
@implementation ScramAppDelegate
@synthesize window;
-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
tabBarController = [[UITabBarController alloc] init];
[window addSubview:[tabBarController view]];
[window makeKeyAndVisible];
return YES;
}
-(void)dealloc {
[tabBarController release];
[window release];
[super dealloc];
}
cheers Gary
I personally don’t bother with
@propertys for my view controllers in my application delegate class. Mainly because the app delegate sits at the top of the view hierarchy, and it doesn’t need to expose its member variables to anyone.Another reason not to comes from the line:
Since if
tabBarControlleris a@propertyset toretain, you’ll double-retain the object, which is a form of memory leak (although relatively benign since it happens at the app delegate level).