为什么 Objective-C 使用 YES 和 NO 而不是 1 和 0? [英] Why does Objective-C use YES and NO instead of 1 and 0?
本文介绍了为什么 Objective-C 使用 YES 和 NO 而不是 1 和 0?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Objective-C 使用 YES 和 NO 而不是 1 和 0 是否有任何技术原因,或者只是为了使其更具可读性?
Is there any technical reason why Objective-C uses YES and NO instead of 1 and 0, or is it simply to make it more readable?
推荐答案
typedef signed char BOOL;
// BOOL is explicitly signed so @encode(BOOL) == "c" rather than "C"
// even if -funsigned-char is used.
#define OBJC_BOOL_DEFINED
#define YES (BOOL)1
#define NO (BOOL)0
(供参考)
[button setAttr:YES];
恕我直言,听起来更好……
Sounds nicer IMHO then...
[button setAttr:TRUE];
这篇关于为什么 Objective-C 使用 YES 和 NO 而不是 1 和 0?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文