Unboxed BOOLs in Objective-C literal syntax giving error

I was just experimenting with the new Objective-C syntax introduced as part of Xcode 4.4.

Dictionaries, integers and arrays work fine, but I had a problem with the job BOOL. eg:.

NSDictionary *myDict = @{
    @"foo": @"bar",
    @"test": @YES
};

gives me "Unexpected type name" BOOL ": expected expression" in a boolean string.

However @(YES), @1, @trueeverything works fine.

This article: http://clang.llvm.org/docs/ObjectiveCLiterals.html suggests it @YESshould work.

I also tried this on my line: NSNumber *myNum = @YES;and get the same error.

error?!

+5
2

, Apple

#define YES (BOOL)1
#define NO  (BOOL)0

#define YES ((BOOL)1)
#define NO  ((BOOL)0)

SDK.

+3

BOOL , IOS Mac SDK, SDK ( iOS 5.1) , @(YES).

, , Subscriptip .

( : http://jamesdempsey.net/2012/07/30/moving-to-new-objective-c-literals/)

+1

All Articles