Expression in FOR command (for (int i=0; i < ([arr count]-1);i++){})

后端 未结 3 885
时光说笑
时光说笑 2021-01-02 23:08

I have a problem that I can not understand

NSArray *emptyArr = @[];
for (int i=0; i < ([emptyArr count]-1) ; i++) {
    NSLog(@\"Did run for1\");
}
         


        
3条回答
  •  感情败类
    2021-01-03 00:10

    [emptyArr count]-1 is never less than 0 since it is unsigned. I'm guessing if you do ((int)[emptyArr count]-1), you will get the correct behavior.

提交回复
热议问题