开发者

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 and do/while loops).

  • break can be used in those same looping constructs as well as in switch statements.


Yes, you can. They work the same way. break exits the loop and continue goes to the beginning and checks the condition again.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜