can I "break"/"continue" in a while loop in objective-c?
can I "break"/"continue" in a while loop in objective开发者_StackOverflow中文版-c?
(or are these reserved only for for loops)
Yes of course you can! Give it a try!
From Apple's Objective-C docs:
Objective-C is defined as a small but powerful set of extensions to the standard ANSI C language.
So break
and continue
can be used wherever they are permitted in C.
continue
can be used in looping constructs (for
,while
anddo/while
loops).break
can be used in those same looping constructs as well as inswitch
statements.
Yes, you can. They work the same way. break
exits the loop and continue
goes to the beginning and checks the condition again.
精彩评论