3

Any idea why I get these messages:

NSAutoreleasePool is unavailable: not available in automatic reference counting mode

ARC forbids explicit message send of 'release'

in this code:

#import <UIKit/UIKit.h>

int main(int argc, char *argv[]) {

    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
    int retVal = UIApplicationMain(argc, argv, nil, nil);
    [pool release];
    return retVal;
}
Brad Larson
  • 170,088
  • 45
  • 397
  • 571

3 Answers3

7

This is because you are compiling with Automatic Reference Counting on. You need to use a different construct with ARC:

@autoreleasepool {
    // Your code
}

Another option is to turn off ARC for a specific file.

Community
  • 1
  • 1
Sergey Kalinichenko
  • 714,442
  • 84
  • 1,110
  • 1,523
7

Yeah, you have Automatic Reference Counting enabled, which doesn't allow you to explicitly use 'release'. You need to either disable ARC or change your main method to look like this:

int main(int argc, char *argv[])
{
    @autoreleasepool {
        return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
    }
}
Michael Frederick
  • 16,664
  • 3
  • 43
  • 58
0

Under targets->Build settings->Apple LLVM Complailer 3.0

Objective-C Garbage Collection (change to ) Supported [ -fobjc-gc]