December 2013
Intermediate to advanced
132 pages
1h 58m
English
CHAPTER 14
![]()
If Statements
If Statements Defined
If statements are used when you want to make a choice to execute code based on the trueness of a condition. To make this work, you evaluate an expression that uses relational operators to yield a YES or NO result. If you evaluate an express to be true, then you can execute the code; otherwise you can ignore the code.
You need the if keyword and an expression here along with a code block to use the if statement.
if(1 < 2){ NSLog(@"That is true");}
The statement is saying that if 1 is less than 2, then execute the code that will print out the string “That is true” to the console log.
Else Keyword ...
Read now
Unlock full access