0

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.

HackyStack
  • 4,887
  • 3
  • 22
  • 28

3 Answers3

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
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