Apple announced support for ARC (Automatic Reference Counting) from iOS 5.
Prior to iOS 5, (i.e. Non-ARC) developer had to keep track of each object allocation manually and release after that object was not needed. Non-ARC also know as MRC (Manual Reference Counting).
ARC is not a runtime mechanism rather, it is a compiler level feature that automatically inserts release/retain statement during the compilation.
Developer can mixed up ARC and MRC files in a project as well as code snippet in a single source file.
- Exclude Non-ARC file from being compiled with ARCYou can do that by setting the flag on the .m file:Steps :~
- Click the Project
- Build Phases Tab
- Compile Sources Section
- Double Click on the file name and add -fno-objc-arc to the popup window.
Note: If you want to include a file in ARC, you can use the -fobjc-arc flag.
- Mixing ARC with Non-ARC code in a source file.You can use __has_feature, like this:#if __has_feature(objc_arc)// ARC is OnNSLog(@"ARC is On");#else// ARC is OffNSLog(@"ARC is Off");#endif