I am working with the following for loop:
for (int intPrjName = 0; intPrjName < [arrPrjName count]; intPrjName++)
I have a if/else stat
If you want to show only one alert in case of failed condition that would probably mean you don't want to continue the loop. So as Jason Coco mentioned in his comment, you break from the loop. Here's a simple example on how to do this:
for (int intPrjName = 0; intPrjName < [arrPrjName count]; intPrjName++) {
if (condition) {
// do something
} else {
break;
}
}
Otherwise, if you want to check some condition for every element of the array, you would probably want to keep track of failures and show user the summary (could be an alert message, another view, etc). Short example:
NSUInteger numFailures = 0;
for (int intPrjName = 0; intPrjName < [arrPrjName count]; intPrjName++) {
if (condition) {
// do something
} else {
numFailures++;
}
}
UIAlertView *alert = [[[UIAlertView alloc] initWithTitle:title
message:@"Operation failed: %d", numFailures
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil] autorelease];
[alert show];
Good luck!