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
  • 169,393
  • 45
  • 393
  • 567

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
  • 697,062
  • 78
  • 1,055
  • 1,465
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
  • 17,165
  • 3
  • 42
  • 57
0

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

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