Skip to content

IGListIndexSetResult and IGListIndexPathResult docs say updates use new index #408

@diogot

Description

@diogot

IGListIndexSetResult updates contains index of old collection

New issue checklist

General information

  • IGListKit version: 2.1.0
  • iOS version(s): 9,10
  • CocoaPods/Carthage version: 1.1.1
  • Xcode version: 8.2.1
  • Devices/Simulators affected: All tested
  • Reproducible in the demo project?: Yes

Description

In IGListIndexSetResult documentation can be read:

/**
 The indexes in the new collection that need updated.
 */
@property (nonatomic, strong, readonly) NSIndexSet *updates;

So it's expected that all indexes on updates refer to objects in new collection, although if you have an old collection with two elements and a new collection only with the second element updated we got an index on updates that are out of bounds the new collection. This test will fail on the last assert:

func testDiffingSwiftClassWithDeleteAndUpdates() {
    let o = [SwiftClass(id: 0, value: "a"), SwiftClass(id: 1, value: "b")]
    let n = [SwiftClass(id: 1, value: "c")]
    let result = IGListDiff(o, n, .equality)
    XCTAssertEqual(result.deletes, IndexSet(integer: 0))
    XCTAssertEqual(result.inserts.count, 0)
    XCTAssertEqual(result.moves.count, 0)
    XCTAssertEqual(result.updates, IndexSet(integer: 0))
}

In this case results.updates contains IndexSet(integer: 1), which can only refers to the old collection.

My doubt here is if the issue is on the documentation or this is a bug.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions