Automatic Reference Counting (ARC) is a compilation-level feature used to develop Cocoa programs for Automatic memory management.
1: In XCode 4.2, create a project using the template, which will use the "ARC feature" by default.
2: You can select the project, Building Settings, and then find the Objective C Automatic Reference Counting (No, you can find it) for the created Project. Set it to No.
---- Theoretical basis of ARC ---
The working principle of ARC is that when you compile a program, the memory operation code (retain, release or autorelease) is automatically added to the desired position. That is, the same memory management mechanism as Manual Reference Counting (Manual Reference Counting) is used at the underlying layer. However, XCode automatically adds code for memory operations during compilation, which simplifies programming.
-Fobjc-ARC must be added to the compilation option when arc is enabled. However, this is done by XCode when creating a project template.
In versions earlier than XCode 4.2, ARC is not supported.
There are also requirements for the operating system: Mac OS X v10.6 or v10.7 (64-bit applications), iOS4 or iOS5. Note: Mac OS X v10.6 and iOS4 do not support weak references (weak references: what is weak references ).
Xcode 4.2 provides a tool named "Convert to Objective-C Automatic Reference Counting". Under the Edit-> Convert menu, you can automatically convert the old code using Manual Reference Counting into new code using ARC (for example, removing the call to retain and release ).