diff --git a/CHANGELOG.md b/CHANGELOG.md index c82063b4..15d954b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,8 @@ The changelog for `IGListKit`. Also see the [releases](https://github.com/instag - Added `IGListCollectionScrollingTraits` for exposing `UICollectionView` scrolling traits to section controllers via `IGListCollectionContext`. [Adam Stern](https://github.com/adamastern) (tbd) +- `IGListBindingSectionController` no longer asserts when reloading the entire section. A warning message is now logged if the entire section is going to be reloaded. [Jeff Bailey](https://github.com/jeffbailey) (#1213) + ### Fixes - Experimental fix to get the `UICollectionView` for batch updating immediately before applying the update. [Ryan Nystrom](https://github.com/rnystrom) (tbd) diff --git a/Source/IGListBindingSectionController.m b/Source/IGListBindingSectionController.m index 073ac314..0882ddd7 100644 --- a/Source/IGListBindingSectionController.m +++ b/Source/IGListBindingSectionController.m @@ -115,9 +115,12 @@ typedef NS_ENUM(NSInteger, IGListDiffingSectionState) { NSArray *viewModels = [self.dataSource sectionController:self viewModelsForObject:object]; self.viewModels = objectsWithDuplicateIdentifiersRemoved(viewModels); } else { - IGAssert([oldObject isEqualToDiffableObject:object], - @"Unequal objects %@ and %@ will cause IGListBindingSectionController to reload the entire section", - oldObject, object); +#if IGLK_LOGGING_ENABLED + if (![oldObject isEqualToDiffableObject:object]) { + IGLKLog(@"Warning: Unequal objects %@ and %@ will cause IGListBindingSectionController to reload the entire section", + oldObject, object); + } +#endif [self updateAnimated:YES completion:nil]; } } diff --git a/Tests/Objects/IGTestDiffingObject.m b/Tests/Objects/IGTestDiffingObject.m index ff14fb5a..e8a662f8 100644 --- a/Tests/Objects/IGTestDiffingObject.m +++ b/Tests/Objects/IGTestDiffingObject.m @@ -28,8 +28,18 @@ return self.key; } -- (BOOL)isEqualToDiffableObject:(id)object { - return YES; +- (BOOL)isEqualToDiffableObject:(id)object { + if (object == self) { + return YES; + } + if ([object isKindOfClass:[IGTestDiffingObject class]]) { + /* A simple equality test that only looks at the number of objects for the key. + It does not currently test the equality of each of the objects. */ + IGTestDiffingObject *testDiffingObject = (IGTestDiffingObject *)object; + return self.objects.count == testDiffingObject.objects.count; + } + + return NO; } @end