What is the difference between BOOL
and Boolean
in Objective C ?
Does it matter which one is used?
If not, why do they both exist?
Thanks
So the answer is both are one and the same and both can be used. But it is recommended to use the bool as that is the alias for the class System. Boolean. In other words the Boolean represents the System.
In C++ boolean is actually an integer. However, a bool in C# is a data type that cannot be casted to any other primitive type. In the field of computers and electronics, Boolean refers to a data type that has two possible values representing the true and false.
For this, Java has a boolean data type, which can store true or false values.
The bool type keyword is an alias for the . NET System. Boolean structure type that represents a Boolean value, which can be either true or false . To perform logical operations with values of the bool type, use Boolean logical operators.
There's no functional difference1 between Objective-C's BOOL
data type and the various flavors of boolean types provided by, e.g., stdbool.h
for C. However, idiomatic Objective-C code uses the BOOL
type (and the values YES
and NO
) for boolean values.
1. There are some differences. For example, a BOOL
is actually a signed char
, whereas (on my machine) stdbool.h
defines _Bool_
and bool
to be an int
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With