I've an if statement, used to check if an indice is less than the end of the array. This is not working when the value of "i" is -1.
NSMutableArray *myArray = [NSMutableArray array];
[myArray addObject:@"coucou"];
int i = -1;
// Not working
if (i < ([myArray count] - 1) ){
NSLog(@" first ok ");
}
// Fix
int count = [myArray count] - 1;
if ( i < count ){
NSLog(@" second ok ");
}
This is what i need to do to get it working (same algorithm, but using an intermediate variable to store the size of the array) Anyone know why ?