首页 > 代码库 > oc goto语法
oc goto语法
//这一句写不写都可以,写的话一个警告,如果下面语句报错,就写上这一句
// struct label *jumpTo;
for (int i=0; i<10; i++) {
NSLog(@"0000====%d",i);
if (i==5) {
gotojumpTo;
}
NSLog(@"1111====%d",i);
jumpTo:NSLog(@"跳到这一行");
}
运行结果
2014-12-17 17:46:43.465 Mustdemo[1335:613765] 0000====0
2014-12-17 17:46:43.466 Mustdemo[1335:613765] 1111====0
2014-12-17 17:46:43.466 Mustdemo[1335:613765]跳到这一行
2014-12-17 17:46:43.466 Mustdemo[1335:613765] 0000====1
2014-12-17 17:46:43.466 Mustdemo[1335:613765] 1111====1
2014-12-17 17:46:43.466 Mustdemo[1335:613765]跳到这一行
2014-12-17 17:46:43.466 Mustdemo[1335:613765] 0000====2
2014-12-17 17:46:43.466 Mustdemo[1335:613765] 1111====2
2014-12-17 17:46:43.466 Mustdemo[1335:613765]跳到这一行
2014-12-17 17:46:43.467 Mustdemo[1335:613765] 0000====3
2014-12-17 17:46:43.467 Mustdemo[1335:613765] 1111====3
2014-12-17 17:46:43.467 Mustdemo[1335:613765]跳到这一行
2014-12-17 17:46:43.467 Mustdemo[1335:613765] 0000====4
2014-12-17 17:46:43.467 Mustdemo[1335:613765] 1111====4
2014-12-17 17:46:43.467 Mustdemo[1335:613765]跳到这一行
2014-12-17 17:46:43.468 Mustdemo[1335:613765] 0000====5
2014-12-17 17:46:43.469 Mustdemo[1335:613765]跳到这一行
2014-12-17 17:46:43.469 Mustdemo[1335:613765] 0000====6
2014-12-17 17:46:43.469 Mustdemo[1335:613765] 1111====6
2014-12-17 17:46:43.470 Mustdemo[1335:613765]跳到这一行
2014-12-17 17:46:43.471 Mustdemo[1335:613765] 0000====7
2014-12-17 17:46:43.472 Mustdemo[1335:613765] 1111====7
2014-12-17 17:46:43.472 Mustdemo[1335:613765]跳到这一行
2014-12-17 17:46:43.472 Mustdemo[1335:613765] 0000====8
2014-12-17 17:46:43.472 Mustdemo[1335:613765] 1111====8
2014-12-17 17:46:43.472 Mustdemo[1335:613765]跳到这一行
2014-12-17 17:46:43.472 Mustdemo[1335:613765] 0000====9
2014-12-17 17:46:43.473 Mustdemo[1335:613765] 1111====9
2014-12-17 17:46:43.473 Mustdemo[1335:613765]跳到这一行
oc goto语法