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

后端 未结 13 607
梦如初夏
梦如初夏 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:18

    Just for grins, how about changing this true/false check into a method and using return statements:

    - (bool) checkTrueFalse: parameters{
    
       for ( ...) {
          for ( ... ) {
    
             if (...) {
                return true;
             }
    
          }
       }
       return false;
    }
    

提交回复
热议问题