In Objective-C I can initialize BOOL variable with YES or TRUE. Is there a reason for this?
BOOL test = false;
BOOL test = NO;
Are they the same?
In Objective-C I can initialize BOOL variable with YES or TRUE. Is there a reason for this?
BOOL test = false;
BOOL test = NO;
Are they the same?
true
and false
comes from c / c++
#ifndef __cplusplus
#define bool _Bool
#define true 1
#define false 0
YES
and NO
is from Objective-C
#if __has_feature(objc_bool)
#define YES __objc_yes
#define NO __objc_no
#else
#define YES ((BOOL)1)
#define NO ((BOOL)0)
#endif
Yes. false
is left over from C, NO
is more prevalent in idiomatic iOS code and libraries.