Found a situation for which I can not find an explanation.
I have an array of arrays in objective-c. this situation the array has 4 empty arrays.
NSArray *dados = [[NSArray alloc] initWithObjects:
[[NSArray alloc] init],
[[NSArray alloc] init],
[[NSArray alloc] init],
[[NSArray alloc] init],
nil];
I want a "for" to go through an internal array if it has two or more numbers.
for(int i=0; i<((NSArray *)[dados objectAtIndex:1]).count-1;i++){
NSLog(@"do anything");
}
this "for" enter into infinite loop.
However if I use a "NSLog" tells me that the condition is -1, and the "is" not supposed to happen
NSLog(@"%d",((NSArray *)[dados objectAtIndex:1]).count-1);
2014-02-20 15:37:42.563 iKL Time-sheet[31666:a0b] -1
how is it possible that this "for" becomes an infinite loop when the stop condition is 0 <-1?
thought to be a curious case, if someone can explain what is going to be able to better understand the language I thanked
---------------------//----------------
answer:
for(int i=0; i<(int)(((NSArray *)[dados objectAtIndex:1]).count-1);i++){
NSLog(@"do anything");
}
with this cast works well, the explanation for this lies in the answer below