Actually there is no difference between YES
, TRUE
and true
those all represent a true state represented by 1.
And NO
, false
, FALSE
is represents a false state represented by 0.
You can also use:
BOOL aBool = 1;
which is equivalent to BOOL aBool = true;
and BOOL aBool = TRUE;
and BOOL aBool = YES;
But:
BOOL bBool = 7;
if (bBool)
{
NSLog(@"bBool is YES!\n");
}
if (bBool != YES) {
NSLog("bBool is not YES!\n");
}
Will output like:
b is YES!
b is not YES!
This is because direct comparison with YES will fail when the value of a BOOL
type is a non-zero value other than 1.
Here is a nice article for you.