I saw the "new type" BOOL
(YES
, NO
).
I read that this type is almost like a char.
For testing I did :
NSLog(@"Size of BOOL %d", sizeof(BOOL));
NSLog(@"Size of bool %d", sizeof(bool));
Good to see that both logs display "1" (sometimes in C++ bool is an int and its sizeof is 4)
So I was just wondering if there were some issues with the bool type or something ?
Can I just use bool (that seems to work) without losing speed?
Best Answer
From the definition in
objc.h
:So, yes, you can assume that BOOL is a char. You can use the (C99)
bool
type, but all of Apple's Objective-C frameworks and most Objective-C/Cocoa code uses BOOL, so you'll save yourself headache if the typedef ever changes by just using BOOL.