I've got code mixed up in my Project both applying coding style for ARC and some are not. Then I come across a solution to set some symbols or Flags: -fno-objc-arc
My question is, what are these Flags? and what do these symbols mean -fno-objc-arc? Are there more of these?
The -fno-objc-arc
flag is for the compiler, not for the linker. It tells the compiler that your Objective C code will be doing all the releasing and retaining manually. This is necessary because the newly added ARC mode prohibits explicit use of retain
, release
, autorelease
, dealloc
, and so on; you cannot call them even through a selector.
Converting all your code to ARC may be a large task, so the compiler supports both the old and the new style of code. You must tell the compiler if the file you're compiling is old or new; you do it by passing the -fno-objc-arc
flag.
There are many other compiler flags. They let you control the way the code is compiled and optimized, the way the errors and warnings are reported back to you, the paths where your headers are located, and so on. Type man gcc
in the terminal window to see the list of compiler options.
ARC stands for Automatic Reference Counting. Here is some information lifted from the Apple Developer site:
Automatic Reference Counting
Automatic Reference Counting (ARC) for
Objective-C makes memory management the job of the compiler. By
enabling ARC with the Apple LLVM compiler, you will never need to type
retain or release again, dramatically simplifying the development
process, while reducing crashes and memory leaks. The compiler has a
complete understanding of your objects, and releases each object the
instant it is no longer used, so apps run as fast as ever, with
predictable, smooth performance.
It is quite common for ARC to be disabled when compiling older, non compliant, code.