How can I break out of two nested for loops in Objective-C?

后端 未结 13 634
梦如初夏
梦如初夏 2020-12-01 00:49

I have two for loops nested like this:

for(...) {
    for(...) {

    }
}

I know that there is a break statement. But I am con

13条回答
  •  北荒
    北荒 (楼主)
    2020-12-01 01:05

    Other than the already mentioned flag variable or goto you could throw an Objective-C exception:

    @try {
      for() {
        for() {
           @throw ...
        }
      }
    }
    @catch{
      ...
    }
    

提交回复
热议问题