Reputation: 1611
I get 'expected expression' error for below code in Xcode5. I created a command line tool project using Xcode5. Any idea of this error? My build setting does have ARC enabled.
#include <stdio.h>
int main(int argc, const char * argv[])
{
@autoreleasepool {
NSMutableArray *items = [[NSMutableArray alloc] init];
[items addObject:@"One"];
[items addObject:@"Two"];
[items addObject:@"Three"];
[items insertObject:@"Zero" atIndex:0];
items = nil;
}
return 0;
}
Upvotes: 0
Views: 957
Reputation: 112857
First eliminate the extra "@".
Import Foundation:
#import <Foundation/Foundation.h>
Next:
items = null;
replaced the objects added to items
, is that what you want?
Also null
is not an Objective-C construct, rather it is an undeclared identifier. Perhaps it should be:
items = nil;
The following compiles error free:
#import <Foundation/Foundation.h>
int main(int argc, char *argv[]) {
@autoreleasepool {
NSMutableArray *items = [[NSMutableArray alloc] init];
[items addObject:@"One"];
[items addObject:@"Two"];
[items addObject:@"Three"];
[items insertObject:@"Zero" atIndex:0];
items = nil;
}
}
Upvotes: 2