What values should I use for iOS boolean states?

后端 未结 5 1533
执笔经年
执笔经年 2021-01-04 10:23

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

YES
NO
TRUE
FALSE
true
false

Which ones should I use

5条回答
  •  余生分开走
    2021-01-04 11:11

    I think all of them are okay. But personally, I'd like to use YES/NO.

    I found a doc called Objective-C Runtime Reference:

    Boolean Values These macros define convenient constants to represent Boolean values.

    #define YES (BOOL)1
    #define NO (BOOL)0

    Constants

    YES
    Defines YES as 1.
    Available in iOS 2.0 and later.
    Declared in NSObjCRuntime.h.

    NO
    Defines NO as 0.
    Available in iOS 2.0 and later.
    Declared in NSObjCRuntime.h.

    Declared In
    objc.h

提交回复
热议问题