Objective-C continue 语句
Objective-C 编程语言中的 continue 语句有点像 break 语句。然而,continue 不是强制终止,而是强制开始下一个循环,跳过中间的任何代码。
对于 for 循环,continue 语句导致直接执行循环的条件判断和增量部分。对于 while 和 do…while 循环,continue 语句使程序控制传递给条件判断。
语法
Objective-C 的 continue 语句的语法如下:
continue;
流程图

实例
#import <Foundation/Foundation.h>int main () {/* local variable definition */int a = 10;/* do loop execution */do {if( a == 15) {/* skip the iteration */a = a + 1;continue;}NSLog(@"value of a: %d\n", a);a++;} while( a < 20 );return 0;}
结果如下:
2022-09-07 22:20:35.647 demo[29998] value of a: 102022-09-07 22:20:35.647 demo[29998] value of a: 112022-09-07 22:20:35.647 demo[29998] value of a: 122022-09-07 22:20:35.647 demo[29998] value of a: 132022-09-07 22:20:35.647 demo[29998] value of a: 142022-09-07 22:20:35.647 demo[29998] value of a: 162022-09-07 22:20:35.647 demo[29998] value of a: 172022-09-07 22:20:35.647 demo[29998] value of a: 182022-09-07 22:20:35.647 demo[29998] value of a: 19