<i id='0vKlr'><tr id='0vKlr'><dt id='0vKlr'><q id='0vKlr'><span id='0vKlr'><b id='0vKlr'><form id='0vKlr'><ins id='0vKlr'></ins><ul id='0vKlr'></ul><sub id='0vKlr'></sub></form><legend id='0vKlr'></legend><bdo id='0vKlr'><pre id='0vKlr'><center id='0vKlr'></center></pre></bdo></b><th id='0vKlr'></th></span></q></dt></tr></i><div id='0vKlr'><tfoot id='0vKlr'></tfoot><dl id='0vKlr'><fieldset id='0vKlr'></fieldset></dl></div>

    1. <small id='0vKlr'></small><noframes id='0vKlr'>

        <bdo id='0vKlr'></bdo><ul id='0vKlr'></ul>
    2. <tfoot id='0vKlr'></tfoot>
      <legend id='0vKlr'><style id='0vKlr'><dir id='0vKlr'><q id='0vKlr'></q></dir></style></legend>

      我应该为 iOS 布尔状态使用什么值?

      时间:2023-10-05

      • <i id='zXlYg'><tr id='zXlYg'><dt id='zXlYg'><q id='zXlYg'><span id='zXlYg'><b id='zXlYg'><form id='zXlYg'><ins id='zXlYg'></ins><ul id='zXlYg'></ul><sub id='zXlYg'></sub></form><legend id='zXlYg'></legend><bdo id='zXlYg'><pre id='zXlYg'><center id='zXlYg'></center></pre></bdo></b><th id='zXlYg'></th></span></q></dt></tr></i><div id='zXlYg'><tfoot id='zXlYg'></tfoot><dl id='zXlYg'><fieldset id='zXlYg'></fieldset></dl></div>

          <tfoot id='zXlYg'></tfoot>
            <tbody id='zXlYg'></tbody>
            • <bdo id='zXlYg'></bdo><ul id='zXlYg'></ul>
              <legend id='zXlYg'><style id='zXlYg'><dir id='zXlYg'><q id='zXlYg'></q></dir></style></legend>
            • <small id='zXlYg'></small><noframes id='zXlYg'>

                本文介绍了我应该为 iOS 布尔状态使用什么值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                在 iOS 中,我似乎有许多适合布尔值的选项:

                It appears that in iOS I have a number of options that seem to fit for boolean values:

                YES
                NO
                TRUE
                FALSE
                true
                false
                

                我应该使用哪些?在这种特殊情况下,我隐藏了一个标签,所以我应该将 hidden 属性设置为 YESTRUEtrue?

                Which ones should I use? In this particular case I'm hiding a label, so should I set the hidden property to YES, TRUE, or true?

                推荐答案

                简答:你应该更喜欢 YESNO 来设置 BOOL 类型的基础属性.

                Short answer: you should prefer YES and NO for setting foundation properties of type BOOL.

                对于长答案,让我们先看看这些常量是在哪里定义的:

                For the long answer, let's first see where are these constants defined:

                • truefalse 来自 stdbool.h;它们是 #define-d as 10
                • TRUEFALSE 来自 CFBase.h;它们是 #define-d as 10
                • YESNO 来自 NSObjCRuntime.h.这就是 signed chartypedef-ed 为 BOOL 的地方,它的两个值是 #define-d 为((BOOL)1)((BOOL)0)__objc_yes/__objc_no 如果 objc_bool 支持.
                • true and false are from stdbool.h; they are #define-d as 1 and 0
                • TRUE and FALSE are from CFBase.h; they are #define-d as 1 and 0
                • YES and NO are from NSObjCRuntime.h. This is where signed char is typedef-ed as BOOL, and its two values are #define-d as ((BOOL)1) and ((BOOL)0) or __objc_yes/__objc_no if objc_bool is supported.

                基础类始终使用 BOOL,它是 signed chartypedef,来表示其布尔属性.由于前两对被转换为 int 常量,使用它们可能会导致警告,尽管它可能会正常工作.但是,YESNO 常量以最适合您的编译器的方式定义,无论其版本如何.因此,我建议在整个代码中始终使用 YESNO.

                The foundation classes consistently use BOOL, which is a typedef for signed char, to represent its boolean properties. Since the first two pairs get converted to int constants, using them may result in warnings, though it would probably work correctly anyway. The YES and NO constants, however, are defined in the most compatible way for your compiler, regardless of its version. Therefore, I would recommend using YES and NO consistently throughout your code.

                这篇关于我应该为 iOS 布尔状态使用什么值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                <tfoot id='DQEwY'></tfoot>
                • <bdo id='DQEwY'></bdo><ul id='DQEwY'></ul>

                  <i id='DQEwY'><tr id='DQEwY'><dt id='DQEwY'><q id='DQEwY'><span id='DQEwY'><b id='DQEwY'><form id='DQEwY'><ins id='DQEwY'></ins><ul id='DQEwY'></ul><sub id='DQEwY'></sub></form><legend id='DQEwY'></legend><bdo id='DQEwY'><pre id='DQEwY'><center id='DQEwY'></center></pre></bdo></b><th id='DQEwY'></th></span></q></dt></tr></i><div id='DQEwY'><tfoot id='DQEwY'></tfoot><dl id='DQEwY'><fieldset id='DQEwY'></fieldset></dl></div>

                • <legend id='DQEwY'><style id='DQEwY'><dir id='DQEwY'><q id='DQEwY'></q></dir></style></legend>

                    <small id='DQEwY'></small><noframes id='DQEwY'>

                      <tbody id='DQEwY'></tbody>