Changes

Jump to: navigation, search

The Objective-C switch Statement

3 bytes removed, 19:27, 12 October 2009
Why Use a switch Statement?
== Why Use a switch Statement? ==
For a small number of logical evaluations of a value the ''if ... else if ...'' construct outlined in [[10.Objective-C Flow Control with if and else]] is perfectly adequate. Unfortunately, any more than two or three possible scenarios can quickly make such a construct both time consuming to write and difficult to read. As a case in point consider the following code example. The program is designed to evaluate integer between 0 and 5 entered at the keyboard and to output the word version of the number (zero, one, two etc):
<pre>

Navigation menu