Problems creating my first Obj-C


#1

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:

[color=#008000]
#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;

}

[/color]

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?


#2

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


#3

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.


#4

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