diff --git a/CHANGELOG.md b/CHANGELOG.md index 7faf1a93..cd0d0050 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ The changelog for `IGListKit`. Also see the [releases](https://github.com/instag 3.1.0 (**upcoming release**) ----- -3.0.0 +3.0.0 ----- This release closes the [3.0.0 milestone](https://github.com/Instagram/IGListKit/milestone/3). diff --git a/Source/IGListAdapter.m b/Source/IGListAdapter.m index b45bff77..a91ba6e8 100644 --- a/Source/IGListAdapter.m +++ b/Source/IGListAdapter.m @@ -494,8 +494,11 @@ IGParameterAssert(dataSource != nil); #if DEBUG + NSCountedSet *identifiersSet = [NSCountedSet new]; for (id object in objects) { + [identifiersSet addObject:[object diffIdentifier]]; IGAssert([object isEqualToDiffableObject:object], @"Object instance %@ not equal to itself. This will break infra map tables.", object); + IGAssert([identifiersSet countForObject:[object diffIdentifier]] <= 1, @"Diff identifier %@ for object %@ occurs more than once. Identifiers must be unique!", [object diffIdentifier], object); } #endif diff --git a/Tests/IGListAdapterTests.m b/Tests/IGListAdapterTests.m index a3881b10..3a4491d6 100644 --- a/Tests/IGListAdapterTests.m +++ b/Tests/IGListAdapterTests.m @@ -1248,4 +1248,9 @@ XCTAssertEqual(collectionView1.dataSource, adapter2); } +- (void)test_whenPassingNonUniqueIdentifiers_adapterShouldAssert { + self.dataSource.objects = @[@0, @1, @2, @0]; + XCTAssertThrows([self.adapter reloadDataWithCompletion:nil]); +} + @end diff --git a/Tests/IGListDebuggerTests.m b/Tests/IGListDebuggerTests.m index 695f0045..39aeae43 100644 --- a/Tests/IGListDebuggerTests.m +++ b/Tests/IGListDebuggerTests.m @@ -45,7 +45,7 @@ adapter3.collectionView = collectionView; NSArray *descriptions = [IGListDebugger adapterDescriptions]; - XCTAssertEqual(descriptions.count, 3); + XCTAssertEqual(descriptions.count, 4); } @end