Literal @YES无法在iOS 5 / Xcode 4.4中运行 [英] Literal @YES not working in iOS 5 / Xcode 4.4
问题描述
新的Xcode 4.4已经用完,它应该支持文字,例如
New Xcode 4.4 is out and it should support literals like
@ 42
@String
@ 23.0L
@ {@key:obj}
和
@ [obj1,obj2]
它还应支持 @YES
和 @NO
,其中在定位最新的iOS 5(及之前版本)时无效。
编译后显示错误信息:
and it should also support @YES
and @NO
, which isn't working when targeting latest iOS 5 (and prior).
After compiling it show the error message:
意外类型名称'BOOL':预期表达式
Unexpected type name 'BOOL': expected expression
我知道您可以通过输入 @(YES)
和 @来修复它否)
。但我想知道它没有按预期工作的原因。
I know you can fix it by typing @(YES)
and @(NO)
. But I want to know the reason why it isn't working as expected.
推荐答案
原因是Apple在这里忘了括号:
The reason is Apple forgot the parentheses here:
#define YES (BOOL)1
这将在iOS 6 SDK中修复:
This will be fixed in iOS 6 SDK:
#define YES ((BOOL)1)
在此期间,您必须输入 @(YES)
。
In the meantime you must type @(YES)
.
这篇关于Literal @YES无法在iOS 5 / Xcode 4.4中运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!