# BOOL / bool / Boolean / NSCFBoolean
# BOOL/Boolean/bool/NSCFBoolean
- bool is a datatype defined in C99.
- Boolean values are used in conditionals, such as if or while statements, to conditionally perform logic or repeat execution. When evaluating a conditional statement, the value 0 is considered “false”, while any other value is considered “true”. Because NULL and nil are defined as 0, conditional statements on these nonexistent values are also evaluated as “false”.
- BOOL is an Objective-C type defined as signed char with the macros YES and NO to represent true and false
From the definition in objc.h:
#if (TARGET_OS_IPHONE && __LP64__) || TARGET_OS_WATCH
typedef bool BOOL;
#else
typedef signed char BOOL;
// BOOL is explicitly signed so @encode(BOOL) == "c" rather than "C"
// even if -funsigned-char is used.
#endif
#define YES ((BOOL)1)
#define NO ((BOOL)0)
# BOOL VS Boolean
BOOL
BOOL.
Boolean
- Boolean is an old Carbon keyword , defined as an unsigned char