Reputation: 6973
I have a Console application with Xcode 4.2.1 and the keyword @autolreleasepool is not compiling:
The compiler seems to be set properly for my Console application:
Do you have any suggestion? I want to understand why the new keyword doesn't work if I have Xcode 4.2.1, I know how to write the autoreleasepool using the old syntax.
UPDATE
This is code that does not compile
#include <CoreFoundation/CoreFoundation.h>
int main (int argc, const char * argv[])
{
@autoreleasepool{
NSMutableArray *array;
array = [[NSMutableArray alloc] init];
int i;
for (i = 0; i < 10; i++) {
NSNumber *newNumber =
[[NSNumber alloc] initWithInt:(i * 3)];
[array addObject:newNumber];
}
for ( i = 0; i < 10; i++) {
NSNumber *numberToPrint = [array objectAtIndex:i];
NSLog(@"The number at index %d is %@", i, numberToPrint);
}
}
return 0;
}
Upvotes: 0
Views: 1128
Reputation: 6973
I found the issue! Instead of creating a command line project with a Type = "Foundation" I used Type = "Core Foundation". I changed that to "Foundation" and now it compiles!
Upvotes: 1
Reputation: 84114
Is ARC enable for this file? Check both the project / target level settings and the individual compiler flags for the file.
Upvotes: 0