Is there any technical reason why Objective-C uses YES and NO instead of 1 and 0, or is it simply to make it more readable?
It's just syntax, there's no technical reason for it. They just use YES/NO for their BOOL instead of true/false like c++ does.
The same reason most languages use true
and false
... You can use 1 and 0 if you like, same as any of those other languages.
Really, if you think about it, we're talking about:
#define YES 1
#define NO 0
It's simply nicer to read.
It's the same as true/false..
Don't ask me why they reinvented the wheel and changed the names.
My pesonal guess is, that the language designer thought it would be cool to be different... (Yes, I know I will get downvotes from the fan-boys)..
C (on which Objective-C is based) didn't have a boolean type until C99.
Objective-C was created in the 80s and defined it's own boolean type.
typedef signed char BOOL;
// BOOL is explicitly signed so @encode(BOOL) == "c" rather than "C"
// even if -funsigned-char is used.
#define OBJC_BOOL_DEFINED
#define YES (BOOL)1
#define NO (BOOL)0
(For reference)
[button setAttr:YES];
Sounds nicer IMHO then...
[button setAttr:TRUE];