Objective-C formatting string for boolean?

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

What formatter is used for boolean values?

EDIT:

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

9条回答
  •  难免孤独
    2020-12-13 12:07

    Add this inline function to your .h file:

    static inline NSString* NSStringFromBOOL(BOOL aBool) {
        return aBool? @"YES" : @"NO";
    }
    

    Now you are ready to go...

    NSLog(@"%@", NSStringFromBOOL(BOOL_VAL));
    

提交回复
热议问题