我想在iOS 5中发布UIViewController对象。
在iOS之前的版本(> 5.0)中,我们始终编写代码或维护代码,随后出现内存泄漏的情况,
if(myViewControllerObject != nil){
[myViewControllerObject.view removeFromSuperView];
[myViewControllerObject release];
myViewControllerObject = nil;
}
myViewControllerObject = [[MyViewControllerObject alloc] initWithNibName:@"MyViewControllerObject" bundle:nil];
[self.view addSubview: myViewControllerObject.view];
但是在iOS 5中,我们不能使用 release 方法来释放UIviewController对象,那么我们在iOS 5中需要做什么来维持额外的对象分配和泄漏?
实施此层次结构的最佳方法是什么?
谢谢。
最佳答案
除非您为项目激活自动引用计数,否则您的代码将不会更改为iOS 5。这样一来,由于系统会处理内存管理,因此您将无法使用release
,dealloc
等。
要了解有关ARC的更多信息,请参见以下问题:How does the new automatic reference counting mechanism work?
关于iphone - 在iOS 5中发布UIviewController对象?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9701162/