Parse Issue, Unexpected '@' in program,

Im learning code through xcode on a tutorial but It keeps flagging up unexpected @ in programme. The code I should write following the tutorial should be,



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

NSAutoreleasepool * pool = [ [ NSAutorelease alloc] init ];

}

Xcode flags up to use @autoreleasepool but still shows Parse issue unexpected @ in programme

If you have code that's generating an error, copy and paste that code here. Without seeing the code we can only guess.


How old is the tutorial you're attempting to follow? What kind of a project is it? Current iOS projects have a main() that looks like this:


int main(int argc, char * argv[])
{
    @autoreleasepool {
        return UIApplicationMain(argc, argv, nil, NSStringFromClass([MyAppDelegate class]));
    }
}


But even if not an iOS project, the @autoreleasepool { } syntax should be the same I would think if it's an Objective-C file.

What junkpile said but also...

Are you sure the file has the ".m" (or ".mm") extension? You need those to tell the compiler that you're writing Objective-C (or Objective-C++).

Share and Enjoy

Quinn "The Eskimo!"
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1@apple.com"
Parse Issue, Unexpected '@' in program,
 
 
Q