Objective-C Language NSLog and BOOL type


Example

There is no format specifier to print boolean type using NSLog. One way to print boolean value is to convert it to a string.

BOOL boolValue = YES;
NSLog(@"Bool value %@", boolValue ? @"YES" : @"NO");

Output:

2016-07-30 22:53:18.269 Test[4445:64129] Bool value YES

Another way to print boolean value is to cast it to integer, achieving a binary output (1=yes, 0=no).

BOOL boolValue = YES;
NSLog(@"Bool value %i", boolValue);

Output:

2016-07-30 22:53:18.269 Test[4445:64129] Bool value 1