Usuwanie obiektów w pętli for z NSMutableArray
Pracuję zUITableView
i dla każdego obiektu w tablicy, który jest źródłem danych dlaUITableView
, Usuwam je, jeśli spełniają pewneif
komunikat. Mój problem polega na tym, że usuwa on tylko inny obiekt z tablicy.
Kod:
UIImage *isCkDone = [UIImage imageNamed:@"UITableViewCellCheckmarkDone"];
int c = (tasks.count);
for (int i=0;i<c;++i) {
NSIndexPath *tmpPath = [NSIndexPath indexPathForItem:i inSection:0];
UITableViewCell * cell = [taskManager cellForRowAtIndexPath:tmpPath];
if (cell.imageView.image == isCkDone) {
[tasks removeObjectAtIndex:i];
[taskManager deleteRowsAtIndexPaths:@[tmpPath]
withRowAnimation:UITableViewRowAnimationLeft];
}
}
Co jest z tym nie tak?