What values should I use for iOS boolean states?

后端 未结 5 1512
执笔经年
执笔经年 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:24

    Use YES and NO is the same to use TRUE and FALSE or 1 and 0 respectively.

    And use NSLog to view result like this little example:

    BOOL result;
    result = YES;
    NSLog(@"my boolean result is %@",result ? @"Yes" : @"No");
    

提交回复
热议问题