Files doesn't support the ARC feature, how to deal with

落爺英雄遲暮 提交于 2019-11-27 18:46:24

问题


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.


回答1:


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 on Done. 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.




回答2:


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.



来源:https://stackoverflow.com/questions/8633903/files-doesnt-support-the-arc-feature-how-to-deal-with

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!