In my loop each row is examined and equal to “yes” or “no”. When the loop is finished, I want to know if I got a “yes”.
This is my code:
for( int i=0;i<[car count];i++) {
NSDictionary *test = [car objectAtIndex:i];
if ([[test objectForKey:@"car"] isEqualToString:[test2 objectForKey:@"red"]]) {
NSLog(@"yes");
} else {
NSLog(@"no");
}
}
just want to know how many “yes” I had in my loop
Create a an integer variable to keep track of positive matches, set it to 0 before the loop, then increment it by 1 on every positive match and after the loop check how many you got.