【发布时间】:2012-03-15 02:55:35
【问题描述】:
我有一个 BaseViewController,它是 UITabBarController 的子类,并在这个视图控制器中设置我的视图。
-(void)setUpViews
{
FirstController *mainViewController = [[FirstController alloc] initAssignment:delegate.currentAssignment withMutableArray:myArray];
UINavigationController *firstNavController = [[UINavigationController alloc] initWithRootViewController:mainViewController];
SecondController *secondViewController = [[SecondController alloc] initWithNibName:@"SecondController" bundle:nil];
UINavigationController *secondNavController = [[UINavigationController alloc] initWithRootViewController:secondViewController];
self.viewControllers = [NSArray arrayWithObjects:firstNavController, secondNavController,nil];
firstNavController.tabBarItem.image = [UIImage imageNamed:@"blablabla.png"];
firstNavController.tabBarItem.title = @"Stream";
secondViewController.tabBarItem.image = [UIImage imageNamed:@"blabla.png"];
secondViewController.tabBarItem.title = @"Favourite";
}
现在我有另一个视图控制器,我称之为ViewHandlerController,BaseViewController 的子类。在我的viewDidLoad 在这个viewHandler 中,我调用在BaseViewController 中声明的setUpViews。在我的应用程序的第一个屏幕中,当按下登录按钮时,我实例化了我的ViewHandlerController,并通过使用成功地向我的 tabcontroller 展示了导航控制器。
[[[UIApplication sharedApplication].windows objectAtIndex:0] addSubview:viewControllerHandler.view];
在我的应用程序中。有一个注销按钮。我正在使用NSNotificationCenter 来调用我的 logoutMethod,它在我的第一个屏幕中声明。我的问题是,在这个logoutMethod中,由于用户可以再次登录(logIn - logOut -logIn),如何释放先前分配的对象以避免内存压力?由于我使用的是 ARC,将我的 ViewController 设置为 NIL 是否会进行所有清理工作?
编辑:从 superview 中删除我的 ViewControllerHandler 并将其设置为 nil 是否也有助于释放其子视图?
干杯
【问题讨论】:
标签: objective-c ios memory-management automatic-ref-counting