diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d4b5acf..70a5faa2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -135,6 +135,8 @@ ListDiff(oldArray: [], newArray: [], .equality) - Fixes a bug when reusing `UICollectionView`s with multiple `IGListAdapter`s in an embedded environment that would accidentally `nil` the `collectionView` property of another adapter. [Ryan Nystrom](https://github.com/rnystrom) [(#721)](https://github.com/Instagram/IGListKit/pull/721) +- Fixes a bug where maintaining a reference to a section controller but not the list adapter in an async block could lead to calling `-[IGListAdapter sectionForSectionController:]` (or checking `-[IGListSectionController sectionIndex]`) and receiving an incorrect value. With the adapter check the value would be 0 because the adapter was `nil` and for the section controller property the value would be the last set index value. [Andrew Monshizadeh](https://github.com/amonshiz) [(#709)](https://github.com/Instagram/IGListKit/issues/709) + 2.1.0 ----- diff --git a/Source/IGListAdapter.m b/Source/IGListAdapter.m index e6dadd34..f9ba0a5b 100644 --- a/Source/IGListAdapter.m +++ b/Source/IGListAdapter.m @@ -27,6 +27,8 @@ _collectionView.dataSource = nil; _collectionView.delegate = nil; } + + [self.sectionMap reset]; } diff --git a/Tests/IGListAdapterTests.m b/Tests/IGListAdapterTests.m index cac8ff68..54cf51ea 100644 --- a/Tests/IGListAdapterTests.m +++ b/Tests/IGListAdapterTests.m @@ -1210,7 +1210,8 @@ XCTAssertEqual(sc.sectionIndex, 1); } - XCTAssertEqual(sc.sectionIndex, 1); + XCTAssertEqual(sc.sectionIndex, NSNotFound); + // This will be 0 because wAdapter should be nil and so nil messaging will return 0 XCTAssertEqual([wAdapter sectionForSectionController:sc], 0); }