Suk*_*iya 37 iphone for-loop objective-c
如何在for循环中使用'break'语句继续形成指定的标签?
前;
outer: for(int i = 0;i<[arABFBmatches count];i++){
for(int i = 0;i<[arABFBmatches count];i++){
//
break _____;
}
}
Run Code Online (Sandbox Code Playgroud)
如何突破外线?
bbu*_*bum 106
你的问题很难说.我会解释你想要跳过内部循环的其余迭代并继续外循环?
for (int i = 0; i < [arABFBmatches count]; i++) {
for (int j = 0; j < [arABFBmatches count]; j++) {
if (should_skip_rest)
break; // let outer loop continue iterating
}
}
Run Code Online (Sandbox Code Playgroud)
请注意,我更改了内循环不变量的名称; i
在两者中使用都会引起精神错乱.
如果你想从两个循环中断,我不会使用goto.我会做:
BOOL allDoneNow = NO;
for (int i = 0; i < [arABFBmatches count]; i++) {
for (int j = 0; j < [arABFBmatches count]; j++) {
if (should_skip_rest) {
allDoneNow = YES;
break;
}
}
if (allDoneNow) break;
}
Run Code Online (Sandbox Code Playgroud)
Mat*_*hen 10
大致:
for(int i = 0;i<[arABFBmatches count];i++){
for(int j = 0;j<[arABFBmatches count];j++){
//
goto outer_done;
}
}
outer_done:
Run Code Online (Sandbox Code Playgroud)
Objective-C没有标记的中断.
归档时间: |
|
查看次数: |
58004 次 |
最近记录: |