【发布时间】:2012-12-05 11:36:13
【问题描述】:
我无法理解对象是如何在 ARC 中释放的,对此我仍然感到困惑。
假设我在方法中使用 alloc 创建了一个视图控制器或任何其他方法
-(void) displayView
{
RegViewController *sampleView = [[RegViewController alloc] init];
[sampleView setModalTransitionStyle:UIModalTransitionStyleCrossDissolve];
[sampleView setModalPresentationStyle:UIModalPresentationFormSheet];
[self presentModalViewController:sampleView animated:YES];
}
它是释放方法块完成时创建的对象,还是我们应该通过给 nil 引用来显式释放?
【问题讨论】:
-
使用 ARC 时,当对象超出范围(不再需要)时,编译器将包括对
release方法的必要调用,开始时 ARC 的发布没有区别和一个非 ARC 应用程序。 -
是的,范围是 ARC 的唯一关注点。
标签: objective-c memory-management automatic-ref-counting