This might be a silly question, but I just wanted to know. I want my code to detect if ARC is enabled, programmatically. How do I do that? Is there is any flag that I could check? Actually the problem is that, I have written an open-source library. I have used release and retain in it. if some one else uses my library files using ARC enabled, I dont want them to get any errors. how do I achieve this? or is there any possible ways I can provide any tools to compile my library before using it?
This might be a silly question, but I just wanted to know. I want
Share
This is of course a compile-time check, you cannot check for ARC at runtime.
An alternative would be to set the
-fno-objc-arccompiler flag for your files that use manual memory management in a project that otherwise uses ARC.Whether you want to bother with this at all or just use ARC everywhere depends on how backward-compatible you want/need to be. Code that supports both ARC and MRC can get quite hard to read and maintain.