How to display bool value on console in iPhone C lens

For an object, this

NSLog(@"some object %@", someObject);  

For decimal:

NSLog(@"some object %d", 2.33);  

What does this mean for bool?

+3
source share
1 answer

Treat it as an int:

NSlog(@"%d",yourBool)

... outputs 1 for YES and 0 for NO

If you want to use the YES / NO output:

NSLog(@"%@", (yourBool ? @"YES" : @"NO"));

Reason copied from objc.h:

#define YES             (BOOL)1
#define NO              (BOOL)0




PS: for decimal places (floats) this is not% d .... its:

NSLog(@"%f",2.33);
+7
source

All Articles