NSLog and BOOL type

suggest change

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");
2016-07-30 22:53:18.269 Test[4445:64129] Bool value YES

Another way is to print the integer value: 1 for YES and 0 for NO. That is a decimal integer, not a binary bit string. If BOOL is a signed char, a value other than YES or NO can print as something else.

BOOL boolValue = YES;
NSLog(@"Bool value %i", boolValue);
2016-07-30 22:53:18.269 Test[4445:64129] Bool value 1

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents