The if Statement
The Objective-C programming language provides a general decision-making capability in the form of a language construct known as the if statement. The general format of this statement is shown here:
if ( expression ) program statement
Imagine that you could translate a statement such as “If it is not raining, then I will go swimming” into the Objective-C language. Using the previous format for the if statement, this might be “written” in Objective-C as follows:
if ( it is not raining ) I will go swimming
The if statement is used to stipulate execution of a program statement (or statements, if enclosed in braces) based on specified conditions. I will go swimming if it is not raining. Similarly, in the program statement
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access