Iglistkit: Question about resultForBatchUpdates in IGListIndexSetResult.m

Created on 29 Dec 2016  路  1Comment  路  Source: Instagram/IGListKit

New issue checklist

General information

I'm trying to implement the diff part in Swift. I found this code in IGListIndexSetResult.m resultForBatchUpdates:

// convert all update+move to delete+insert
 const NSUInteger moveCount = moves.count;
    for (NSInteger i = moveCount - 1; i >= 0; i--) {
        IGListMoveIndex *move = moves[i];
        if ([filteredUpdates containsIndex:move.from]) {
            [filteredMoves removeObjectAtIndex:i];
            [filteredUpdates removeIndex:move.from];
            [deletes addIndex:move.from];
            [inserts addIndex:move.to];
        }
    }

In line 5, filteredMoves removes object at index i, since filteredMoves will change when enumerating, this cannot guarantee the specific IGListMoveIndex object will be removed. Was that on purpose?

question

Most helpful comment

I figured this out , the enumeration was reversed.

>All comments

I figured this out , the enumeration was reversed.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

PhilCai1993 picture PhilCai1993  路  3Comments

rnystrom picture rnystrom  路  3Comments

shuhrat10 picture shuhrat10  路  3Comments

rnystrom picture rnystrom  路  3Comments

runmad picture runmad  路  3Comments