<分区>
使用 XCode 4.4 的 Convert to Modern Objective C Syntax,我的 [NSNumber numberWithBool: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
不能,我可以做些什么来补救?