【发布时间】:2013-10-09 11:44:10
【问题描述】:
我有一个问题:
ExploreViewController *vc = [self.storyboard instantiateViewControllerWithIdentifier:@"ProfileViewController"];
vc.id_from = post.user_id;
[self.navigationController pushViewController:vc animated:YES];
如您所见,我实例化了 viewController 并将其推送到 navigationController 中。 vc,应该是 autorelease ,但从不调用 dealloc 方法。
所以,如果我在推送后释放视图控制器:
ExploreViewController *vc = [self.storyboard instantiateViewControllerWithIdentifier:@"ProfileViewController"];
vc.id_from = post.user_id;
[self.navigationController pushViewController:vc animated:YES];
[vc release];
当我弹出视图控制器时会调用dealloc方法,但是如果我再次执行上面的代码,会立即调用dealloc并且应用程序崩溃,因为其他对象没有找到vc。
所以,如果我不释放它,内存会越来越忙。
谢谢大家!
【问题讨论】:
标签: ios objective-c storyboard release dealloc