Reputation: 4486
I have the following statement inside
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
The statement is :
root_view_controller = [[Root_View_Controller alloc] initWithNibName:@"Base_View" bundle : nil];
I am not using ARC, so I am thinking of releasing root_view_controller in
- (void)applicationWillTerminate:(UIApplication *)application
My question is : Is the above practice ok ? And : Is there any other clean up code that should be added before releasing root_view_controller ?
Upvotes: 0
Views: 834
Reputation: 345
- (void)dealloc
{
[_window release];
[_viewController release];
[super dealloc];
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
// Override point for customization after application launch.
self.viewController = [[[MLViewController alloc] initWithNibName:@"MLViewController" bundle:nil] autorelease];
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;
}
If you want release your Root_View_Controller you need to do it in dealloc method like the code above
Upvotes: 2
Reputation: 2664
There is no need to release memory in
- (void)applicationWillTerminate:(UIApplication *)application
because when an app is terminated, the memory it used is released anyway.
Upvotes: 1