Objective-C formatting string for boolean?

后端 未结 9 1727
情深已故
情深已故 2020-12-13 11:38

What formatter is used for boolean values?

EDIT:

Example: NSLog(@\" ??\", BOOL_VAL);, what is ?? ?

9条回答
  •  轮回少年
    2020-12-13 12:02

    I created a category of NSString with this

    + (instancetype)stringWithBool:(BOOL)boolValue {
    return boolValue ? @"YES" : @"NO";
    }
    

    And use it like this:

    [NSString stringWithBool:boolValue];
    

提交回复
热议问题