Type Alias

BOOL

Type to represent a Boolean value.

Declaration 宣言

typedef bool BOOL;

Discussion 解説

BOOL is explicitly signed so @encode(BOOL) is c rather than C even if -funsigned-char is used.

For values, see Boolean Values.

Special Considerations 特別な注意事項

Since the type of BOOL is actually char, it does not behave in the same way as a C _Bool value or a C++ bool value. For example, the conditional in the following code will be false on i386 (and true on PPC):


- (BOOL)value {
    return 256;
}
// then
if ([self value]) doStuff();

By contrast, the conditional in the following code will be true on all platforms (even where sizeof(bool) == 1):


- (bool)value {
    return 256;
}
// then
if ([self value]) doStuff();