The do Statement
The two looping constructs discussed thus far in this chapter both test the conditions before the loop is executed. Therefore, the body of the loop might never be executed if the conditions are not satisfied. When developing programs, you sometimes want to have the test made at the end of the loop instead of at the beginning. Naturally, the Objective-C language provides a special language construct to handle such a situation, known as the do statement. The syntax of this statement is as follows:
do program statementwhile ( expression );
Execution of the do statement proceeds as follows: program statement is executed first. Next, the expression inside the parentheses is evaluated. If the result of evaluating expression is ...
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