I was just experimenting with the new Objective-C literal syntax introduced as part of Xcode 4.4.
Dictionaries, integers, and arrays all work fine, but I’ve been having a problem getting BOOLs to work. e.g.:
NSDictionary *myDict = @{
@"foo": @"bar",
@"test": @YES
};
gives me “Unexpected type name ‘BOOL’: expected expression” on the line with the boolean.
However, @(YES), @1, @true all work fine.
This article: http://clang.llvm.org/docs/ObjectiveCLiterals.html suggests that @YES should work.
I’ve also tried it on its own line: NSNumber *myNum = @YES; and get the same error.
Bug?!
It’s not a bug, it’s because Apple currently does
instead of
which is fixed in the newest SDKs.