Deleting objects within a for loop from a NSMutableArray

前端 未结 2 1529
你的背包
你的背包 2021-01-24 10:11

I am working with a UITableView and for each of the objects in the array that is the datasource for the UITableView, I am deleting them if they meet a

2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-24 10:58

    If you wanted to keep your loop running forwards, you could either:

    decrement i when your condition is met and you removeObjectAtIndex

        if (cell.imageView.image == isCkDone) {
            ...
            --i ;
            ...
        }
    

    or increment i only when your condition is not met:

    for ( int i=0 ; i

提交回复
热议问题