Possible Duplicate:
Objective c formatting string for boolean?
What NSLog
%
-specifier should be used to literally see YES
or NO
when printing a BOOL
?
BOOL var = YES;
NSLog(@"var = %@", (var ? @"YES" : @"NO"));
BOOL
is merely an alias (typedef) for signed char
.
The specifiers supported by NSLog are documented here.
Objective-C booleans (BOOL
) are simply typedef
s to signed char
. Therefore, they are not objects, and aren't handled any differently from other primitive numbers. If you don't care about seeing YES
and NO
, you can simply print them out as you would any other number (with %d
, for instance). If you would like to see YES
and NO
, you can follow Emile's suggestion.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With