terça-feira, 27 de setembro de 2011

iOS Quick Tip - Turning Off Automatic Reference Counting aka ARC

When developing your new apps under the newest XCode beta with iOS 5 you`ll get the ARC as gift, ok not a full git YET, but still a powerful gift.
So the question(s) arises: "What to do with code that isn`t under ARC yet?", "Can I turn it off?", "Can I turn it off only in a few files?"

Easy now, that is not a big trouble, I do hope that Apple engineering team improve this but for now let`s stick with what we got.

Turning ARC off for a new project (XCode Preview 7 onward *we hope*)

This is the easiest way, when creating a new project just check/uncheck "Use Automatic Reference Counting"


Turning it off for a few files
I`m personally not a huge fan of compile parameters but at least we have then when nothing else help us.
So open your project and select your desired target. Then select Build Phases, expand Compile Sources. There you`ll find the files that XCode is compiling, select everyone that will not use ARC and hit "enter". In the white box type -fno-objc-arc and hit enter. Done!



That`s all we need to stop using ARC in some of our project files, and whenever you change your mind just remove the flag.





Nenhum comentário: