@autoreleasepool没有ARC吗? [英] @autoreleasepool without ARC?
问题描述
我是Xcode 4.2的新手,并且尚未完全了解ARC.但是,我确实读过@autoreleasepool代替了手动使用自动释放池,并且在引擎盖下做了一些特殊的魔术处理,以便与ARC配合使用.
I'm new to Xcode 4.2, and I'm not yet fully up to speed on ARC. However, I did read that @autoreleasepool replaces the manual use of autorelease pools and does some special magic under the hood to play nice with ARC.
但是,当我在Xcode 4.2中专门启动了一个新项目,并且将ARC选项关闭了时,我仍然在模板代码中得到@autoreleasepool语句.
Yet, when I start a new project in Xcode 4.2 specifically with the ARC option turned off I still get @autoreleasepool statements in the template code.
这是怎么回事?
推荐答案
来自 http://clang.llvm.org/docs/AutomaticReferenceCounting.html#autoreleasepool :
@autoreleasepool
可以在具有相同语义的非ARC转换单元中使用.
@autoreleasepool
may be used in non-ARC translation units, with equivalent semantics.
和格雷格·帕克(Greg Parker)说 [1]
and Greg Parker says [1] [2]:
如果部署目标足够新,则LLVM 3.0的
@autoreleasepool { ... }
比NSAutoreleasePool快得多.无需ARC. (…)始终有效,但是对于OS X 10.7或iOS 5.0的部署目标,它的运行速度更快.
LLVM 3.0's
@autoreleasepool { ... }
is much faster than NSAutoreleasePool if your deployment target is new enough. No ARC required. (…) always works, but it's faster with deployment target of OS X 10.7 or iOS 5.0.
因此您可以使用@autoreleasepool
而不考虑ARC,它在OS X v10.7 +和iOS 5.0+上将比NSAutoreleasePool
快.
So you may use @autoreleasepool
regardless of ARC, and it’ll be faster than NSAutoreleasePool
on OS X v10.7+ and iOS 5.0+.
这篇关于@autoreleasepool没有ARC吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!