Literal @YES无法在iOS 5 / Xcode 4.4中运行 [英] Literal @YES not working in iOS 5 / Xcode 4.4

查看:183
本文介绍了Literal @YES无法在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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆