HackyStack
HackyStack

Reputation: 5157

How do I prove ARC is working?

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.

Upvotes: 0

Views: 141

Answers (3)

Boris Prohaska
Boris Prohaska

Reputation: 912

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.

Upvotes: 6

zoul
zoul

Reputation: 104145

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

Upvotes: 1

P.J
P.J

Reputation: 6587

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

Upvotes: 0

Related Questions