search

Home  >  Q&A  >  body text

Objective-C 中 BOOL 类型属性的缺省值是多少?

Objective-C 中 BOOL 类型的属性未初始化,那么它的值是默认YES/NO,还是随机的?

高洛峰高洛峰2762 days ago745

reply all(4)I'll reply

  • 黄舟

    黄舟2017-04-28 09:08:24

    The default is NO.

    reply
    0
  • 怪我咯

    怪我咯2017-04-28 09:08:24

    The default value of basic data types in OC is 0, and the type 0 of BOOL represents NO

    reply
    0
  • PHP中文网

    PHP中文网2017-04-28 09:08:24

    The BOOL type is a typedefed char type. When not initialized, it is the same as the C language, which is 0 in ASCII, and the same as 0000 in Unicode

    reply
    0
  • 仅有的幸福

    仅有的幸福2017-04-28 09:08:24

    Member variables have default values:

    Variables Default value
    Byte 0
    short 0
    int 0
    long 0L
    char /u0000'
    float 0.0F
    double 0.0D
    Boolean FALSE
    All pointer variables nil (is the null pointer)

    reply
    0
  • Cancelreply