文件不支持ARC功能,如何处理
我的项目使用 ARC(自动引用计数器),所以当我尝试导入 ASIHTTPRequest 库时,该库有 4 个在实现 autorelease 语句中使用的类,这里是一个示例:
[self setAccessLock:[[[NSRecursiveLock alloc] init] autorelease]];
我得到的错误:
ARC forbids explicit message send of autorelease
我应该做什么来解决这个问题。
My project uses the ARC(Automatic Reference Counter), so when i try to import the ASIHTTPRequest library which has 4 classes that used in their implementation the autorelease statement, here is an example:
[self setAccessLock:[[[NSRecursiveLock alloc] init] autorelease]];
The error that i got:
ARC forbids explicit message send of autorelease
What should i do to solve this problem.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我已经找到了解决方案,我需要为每个不支持 ARC 的文件的编译器标志添加正确的标志。对我来说,我使用 Xcode 4.2,所以在
target -> 下构建阶段 ->编译源代码
,双击要禁用 ARC 功能的文件,然后输入-fno-objc-arc
,然后单击完成
。就完成了;)请注意,如果列表中不存在该文件,您只需单击 + 按钮即可添加它,然后执行上面相同的工作。
I have got the solution, i needed to add the right flags to the compiler flags for each file which doesn't support the ARC. For me, i use Xcode 4.2, so under
target -> Build Phases -> Compile Sources
, double click on the file you want to disable the ARC feature and put-fno-objc-arc
the click onDone
. And it's Done ;)Please note, that if the file doesn't exist on the list, you can just add it by clicking the + button and then perform the same work above.
为该类禁用 ARC
当您迁移项目以使用 ARC 时,-fobjc-arc 编译器标志将设置为所有 Objective-C 源文件的默认值。您可以使用特定类的 -fno-objc-arc 编译器标志来禁用该类的 ARC。
在 Xcode 中,在目标“构建阶段”选项卡中,打开“编译源”组以显示源文件列表。双击要设置标志的文件,在弹出面板中输入 -fno-objc-arc,然后单击“完成”。
Disable ARC for that one class
When you migrate a project to use ARC, the -fobjc-arc compiler flag is set as the default for all Objective-C source files. You can disable ARC for a specific class using the -fno-objc-arc compiler flag for that class.
In Xcode, in the target Build Phases tab, open the Compile Sources group to reveal the source file list. Double-click the file for which you want to set the flag, enter -fno-objc-arc in the pop-up panel, then click Done.