Objective-C formatting string for boolean? Objective-C formatting string for boolean? objective-c objective-c

Objective-C formatting string for boolean?


One way to do it is to convert to strings (since there are only two possibilities, it isn't hard):

NSLog(@" %s", BOOL_VAL ? "true" : "false");

I don't think there is a format specifier for boolean values.


I would recommend

NSLog(@"%@", boolValue ? @"YES" : @"NO");

because, um, BOOLs are called YES or NO in Objective-C.


Use the integer formatter %d, which will print either 0 or 1:

NSLog(@"%d", myBool);