Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Converting individual files to arc?

I've seen lots of info about converting a whole project to arc and then using flags to tell Xcode which ones not to convert.

What about converting only individual files to arc? I tried it, and it runs fine. Can I do that? I'm kind of worried that since the whole project isn't converted to arc if I convert things here and there they'll cause memory leaks.

like image 747
node ninja Avatar asked May 06 '12 09:05

node ninja


2 Answers

Yes, you can. However, you need to tell the compiler which files are not ARC. This you can do in your project settings. Go to your project > Select the target of the app in question > Build Phases. Now drop down the "Compile Sources" and select the files you wish not to compile with ARC, press ENTER and a little popup box will appear. Here you can write -fno-objc-arc. Press Done and you are done.

When compiling, it will try to add automated reference counting to the files which do not have the -fno-objc-arc flag. Very usefull when using non-arc libs such as ASIHTTPRequest or MBProgressHud (and others).

like image 172
Paul Peelen Avatar answered Nov 12 '22 16:11

Paul Peelen


To tell only certain file is ARC use flag:

-fobjc-arc
like image 24
Deepukjayan Avatar answered Nov 12 '22 14:11

Deepukjayan