BOOL, bool, Boolean, and NSCFBoolean
suggest changeboolis a type defined in C99.- Boolean values are used in conditionals, such as
iforwhilestatements, 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”. BecauseNULLandnilare defined as 0, conditional statements on these nonexistent values also evaluate as “false”. BOOLis an Objective-C type. It issigned charon most Apple platforms, and C99boolon 64-bit iOS and on watchOS, with the macrosYESandNOto 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)
NSCFBooleanis a private class in theNSNumberclass cluster. It is a bridge to theCFBooleanReftype, which is used to wrap boolean values for Core Foundation property lists and collections.CFBooleandefines the constantskCFBooleanTrueandkCFBooleanFalse. BecauseCFNumberRefandCFBooleanRefare different types in Core Foundation, they are represented by different bridging classes inNSNumber.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents