Ios – How to print Boolean flag in NSLog

cocoa-touchiosobjective c

Is there a way to print value of Boolean flag in NSLog?

Best Answer

Here's how I do it:

BOOL flag = YES;
NSLog(flag ? @"Yes" : @"No");

?: is the ternary conditional operator of the form:

condition ? result_if_true : result_if_false

Substitute actual log strings accordingly where appropriate.