How to define a BOOL constant?

后端 未结 3 1255
既然无缘
既然无缘 2021-02-19 11:14

I know how to do it for a float:

#define kMyConstant 1.0f

but how could I do that fora BOOL value?

相关标签:
3条回答
  • 2021-02-19 11:47

    I would do it differently:

    enum { MyConstantBool = YES };
    

    It's a constant, it doesn't take up storage space.

    0 讨论(0)
  • 2021-02-19 11:55

    #define kMyConstantBOOL YES

    Or

    static BOOL MyConstantBool = YES;

    0 讨论(0)
  • 2021-02-19 12:02

    Here's an example:

    #define kMyConstant      YES
    #define kMyOtherConstant NO
    
    0 讨论(0)
提交回复
热议问题