The while Statement

The while statement further extends the Objective-C language’s repertoire of looping capabilities. The syntax of this frequently used construct is as follows:

while ( expression )    program statement

The expression specified inside the parentheses is evaluated. If the result of the expression evaluation is true, the program statement that immediately follows is executed. After execution of this statement (or statements, if enclosed in braces), expression is again evaluated. If the result of the evaluation is true, the program statement is again executed. This process continues until expression finally evaluates false, at which point the loop is terminated. Execution of the program then continues with the statement that follows ...

Get Programming in Objective-C, Sixth Edition 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.