0
我在學習objective-c並想澄清一件事:當我使用autoreleasepool時,我應該在使用測試對象後發送autorelease消息嗎?使用@autoreleasepool併發送autorelease消息
for (int i = 0; i < 10; ++i)
{
@autoreleasepool {
TestClass* tc1 = [[TestClass alloc] init];
//....... do some stuff with tc1
[tc1 autorelease];
}
}
好的。因此,如果我使用ARC,即使返回對象表單方法,也不應該執行autorelease操作? – amplifier
@amplifier試試吧!如果你使用ARC,編譯器會在底部使用'autorelease'來啓動你,並且不會編譯你的代碼。 – 2012-12-08 09:10:25
@amplifier(提示:因爲autorelease再一次自動完成了 - [看到這個。](http://www.galloway.me.uk/2012/02/how-does-objc_retainautoreleasedreturnvalue-work/)) – 2012-12-08 09:11:24