Problems creating my first Obj-C


Creating a command line tool of the foundation type, it’s like Xcode refuses to acknowledge @autoreleasepool as valid. Instead I’m having to leave the default template in place and continue on, so it looks like:

#import <Foundation/Foundation.h>

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

NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

// insert code here...
NSLog(@"Hello, World!");

[pool drain];
return 0;



I just delete the comment and “hello world” statement. I’ve double checked that I set up the creation correctly. What am I doing wrong?


Are you running Xcode 4.2? Using ARC? @autoreleasepool is new…


Ah, 4.1. I just got my first Mac about a month ago and had downloaded Xcode. I didn’t think they would update so quickly! Thanks, I will try that.

EDIT: That did the trick! Thanks.


+1 for this! I had downloaded 4.2.1 already but hadn’t run the Install Xcode app.