DenTelezhkin / DTTableViewManager

Protocol-oriented UITableView management, powered by generics and associated types.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

removeItemsAtIndexPaths:indexPaths code issue

orkenstein opened this issue · comments

It always logs DTMemoryStorage: item to delete was not found at indexPath:
Because you kinda mutating while enumerating:

 for (NSIndexPath * indexPath in indexPaths)
    {
        id object = [self objectAtIndexPath:indexPath];

        if (object)
        {
            DTSectionModel * section = [self getValidSection:indexPath.section];
            [section.objects removeObjectAtIndex:indexPath.row];
            [self.currentUpdate.deletedRowIndexPaths addObject:indexPath];
        }
        else
        {
            if (self.loggingEnabled)
            {
                NSLog(@"DTMemoryStorage: item to delete was not found at indexPath : %@ ", indexPath);
            }
        }
    }

Example:
I want to remove (0-1) and (0-2).
Remove (0-1) - okay
objectAtIndexPath:(0-2) returns nil.

You should shift index paths or sort 'em and start from the end.

Yes, you are correct, this is a bug. I've fixed this in DenTelezhkin/DTModelStorage@501f4fd. Seems like starting from the end is good enough approach.

3.0.5 release is using this fix.

Thanks!
You rock.

Отправлено с iPhone

22 янв. 2015 г., в 17:57, Denys Telezhkin notifications@github.com
написал(а):

Closed #17 #17.


Reply to this email directly or view it on GitHub
#17 (comment)
.