@autoreleasepool没有ARC吗? [英] @autoreleasepool without ARC?

查看:93
本文介绍了@autoreleasepool没有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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆