使用XCode 4.4的转换为现代Objective C语法,我的[NSNumber numberWithBool:YES]
调用转换为@(YES)
。我遇到了一些我现在已经忘记的问题,并将它们自己更改为@YES
,这应该是正确的语法。为什么@YES会给出“期望的表达式”错误,但@(是)编译?
但是,这样做给我的错误:
Unexpected type name 'BOOL': expected expression
我知道有一种“表达”的语法,但我不明白为什么我不能简单地用@YES
和@NO
。
// Compiler error:
NSDictionary *userDefaultsDefaults = @{@"hasBeenLaunched": @YES};
// No error
NSDictionary *userDefaultsDefaults = @{@"hasBeenLaunched": @(YES)};
为什么@(YES)
编译而@YES
不和我能做些什么来弥补呢?
你到底在问什么? – 2012-07-28 00:30:19