In objc. H, bool is defined:
Typedef signed Char bool; # define Yes (bool) 1 # define no (bool) 0
From the preceding definition, we find that the value of the Boolean variable is YES/NO, or 1/0. Yes or 1 indicates true, and no or 0 indicates false. For example, you have defined a Boolean variable and assigned a value:
Bool enabled = no; Enabled = 0;
Determine whether the bool value is yes:
If (Enabled = Yes ){}
Or yes can be omitted
If (Enabled ){}
Determine whether the bool value is no:
If (! Enabled ){}
Or
If (enabled! = Yes ){}
Example:
Determines whether a number is a prime number. If yes, yes is returned. If not, no is returned.
-(Bool) isprime :( int num) {// The reader can think about the algorithm by himself. If you do not understand what needs to be explained, please leave a message for (INT I = 2; I <num/2; I ++) {If (Num % I = 0) {return no ;}} return yes ;}