How to print Boolean flag in NSLog?

Devang picture Devang · Jun 15, 2011 · Viewed 191.1k times · Source

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

Answer

BoltClock picture BoltClock · Jun 15, 2011

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.