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 ...
Get Objective-C Quick Syntax Reference now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.