In the Xcode non-ARC project, set some files for ARC support, xcodearc
ARC is a new feature launched by iOS 5, which is called Automation Reference Counting ). Simply put, retain/release is automatically added to the Code. The Code that was manually added to handle the reference count of memory management can be automatically completed by the compiler. This mechanism starts to be imported in iOS 5/Mac OS X 10.7 and can be used in Xcode4.2. A simple understanding of ARC is to allow the compiler (LLVM 3.0) to automatically generate the reference count of instances to manage part of the code During code compilation through the specified syntax. One thing is that ARC is not a GC, but a Static Analyzer tool.
In xCode, you often need to import some external code files. If the imported file uses the ARC mechanism and your current project does not use the ARC, xCode will give a warning or report an error. How can we deal with these problems:
Click the project navigation file --> select Targets --> select Build Phases --> Expand Compile Sources
At this time, we can see that the name of the second column is:Compiler Flags
Double-click the ARC file you want to use and enter-Fobjc-arc,
Now this file can be compiled using the ARC Mechanism during compilation.
Same as above. To prevent code using the ARC mechanism from using the ARC mechanism, you only need to enter -Fno-objc-arc
How can we make the project support both ARC and non-ARC?
If most of your code requires the ARC, set the project to support the ARC, and then for some files that do not need the ARC, add "-fno-objc-ARC" to "compiler flags" of the source file to prohibit arc compilation ". For Xcode 4, you can find "compiler flags" in target-Build Phases-Compile Sources ".
Code to be added when creating a non-arc in xcode
Enter-fno-objc-ARC after the m file of a non-arc Node