Search code examples
objective-ccocoastring-formattingnslogboolean

What format specifier should be used for BOOL?


Possible Duplicate:
Objective c formatting string for boolean?

What NSLog %-specifier should be used to literally see YES or NO when printing a BOOL?


Solution

  • 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.