How to require ARC in a class? How to require ARC in a class? objective-c objective-c

How to require ARC in a class?


The following should work:

#if !__has_feature(objc_arc)#  error Compile me with ARC, please!#endif

Place it at the top of your file.


If it is a complete file, I would recommend adding -fno-objc-arc to the compiler flags to use the non-arc compiler.

Use the macro to compile "parts" of code with the non-arc compiler.for example, use this if you are writing a framework that will be used in both arc and non-arc code bases and write release, deallocs within this macro block