I have a non-ARC project that I added a new file to and set an ARC compiler flag (-fobjc-arc) for. When I make calls to [object release]; in the file, there are no compiler errors thrown. I need to be sure that this file indeed has ARC enabled, how can I prove that? Thanks.
Asked
Active
Viewed 135 times
0
-
Possible duplicate of: http://stackoverflow.com/questions/9462372/how-do-i-know-whether-the-compiler-has-arc-support-enabled – Attila H Jan 17 '13 at 15:12
-
Nope. dealloc is still there to handle CF cleanup. – uchuugaka Jan 17 '13 at 16:01
3 Answers
6
There is no check for ARC at runtime. However, you can check it at compile time:
#if !__has_feature(objc_arc)
//Do the old stuff
#endif
Hope that helps.

zoul
- 102,279
- 44
- 260
- 354

Boris Prohaska
- 912
- 6
- 16
-
Exactly what I was looking for. I set the compiler flag on the wrong target BTW... that was the problem... – HackyStack Jan 17 '13 at 16:00
1
Additionally, if you can call -release
, ARC is off. Once turned on, the compiler will complain about any attempt at manual memory management, like calling -retain
, -release
or [super dealloc]
.

zoul
- 102,279
- 44
- 260
- 354
0
Try this
#if __has_feature(objc_arc)
// ARC is On
NSLog(@"ARC on");
#else
// ARC is Off
NSLog(@"ARC off");
#endif
Hope it helps you..

P.J
- 6,547
- 9
- 44
- 74