What formatter is used for boolean values?
EDIT:
Example: NSLog(@" ??", BOOL_VAL);
, what is ??
?
What formatter is used for boolean values?
EDIT:
Example: NSLog(@" ??", BOOL_VAL);
, what is ??
?
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, BOOL
s are called YES
or NO
in Objective-C.
In Objective-C, the BOOL
type is just a signed char. From <objc/objc.h>
:
typedef signed char BOOL;
#define YES (BOOL)1
#define NO (BOOL)0
So you can print them using the %d
formatter But that will only print a 1
or a 0
, not YES
or NO
.
Or you can just use a string, as suggested in other answers.
Format strings for use with NSLog and [NSString stringWithFormat] are documented here:
BOOL/bool/boolean are not even mentioned...