Reputation: 177
Is there a method can convert a BOOL into NSString in objective-C?
for example:
BOOL a = YES;
NSLog(@"a is %i",a);
but the output is "a is 1", I want it to print YES.
Upvotes: 4
Views: 7138
Reputation: 3796
You can use the conditional operator to return string from the boolean.
BOOL a = YES;
NSLog(@"a is %@", a ? @"YES" : @"NO");
Upvotes: 12