I wonder if someone can explain something, I setup a loop where I wanted to count backwards from 10 to 0 :
for(NSUInteger index = 10; index >= 0; index--) {
NSLog(@"INDEX: %ld", (long)index);
}
This loop runs forever, it does not stop at 0, but keeps going into negative numbers. When I noticed this I changed my code to :
for(NSInteger index = 10; index >= 0; index--) {
NSLog(@"INDEX: %ld", (long)index);
}
The above works fine, but I am curious, why the first example does not work as the numbers generated are all unsigned integers?