The goto Statement
Executing a goto
statement causes a direct branch to be made to a specified point in the program. To identify where in the program the branch is to be made, a label is needed. A label is a name formed with the same rules as variable names; it must be immediately followed by a colon. The label is placed directly before the statement to which the branch is to be made and must appear in the same function or method as the goto
.
For example, the statement
goto out_of_data;
causes the program to branch immediately to the statement that is preceded by the label out_of_data
;. This label can be located anywhere in the function or method, before or after the goto
, and might be used as shown here:
out_of_data: ...
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.