1、当数组为空时进行循环
for (int i = 0; i < [array count] - 1; i++)
{
NSLog(@"i = %d",i);
}
2、此时程序会进入for循环中,为什么?难道 (0 < [array count] - 1) == (0 < -1) ?
3、修改代码这样
int count = [array count] - 1;
for (int i = 0; i < count; i++)
{
NSLog(@"i = %d",i);
}
4、结果程序不进入循环了,说明:(0 < [array count] - 1) != (0 < -1) 是真的!