For loop and if statement

后端 未结 3 504
耶瑟儿~
耶瑟儿~ 2021-01-17 06:22

I am working with the following for loop:

for (int intPrjName = 0; intPrjName < [arrPrjName count]; intPrjName++)

I have a if/else stat

3条回答
  •  Happy的楠姐
    2021-01-17 06:47

    Your problem is a general programing problem. The simplest way is to just use a BOOL flag.

    BOOL alertShown = NO;
    for (int intPrjName = 0; intPrjName < [arrPrjName count]; intPrjName++) {
        if (something) {
            // . . .
        } else {
            if (!alertShown) {
                [self showAlert:intPrjName]; // Or something
                alertShown = YES;
            }
        }
    }
    

提交回复
热议问题