From af984ca81d4d8c4ba3012be1a45f69670a832ccf Mon Sep 17 00:00:00 2001 From: Ryan Nystrom Date: Wed, 22 Mar 2017 09:35:27 -0700 Subject: [PATCH] Assert nil diff identifier, remove if nil Summary: Do not allow `nil` diff identifiers to get through. Pluck the objects if this happens and assert. - Fix the bug if it happens - Assert to tell the developer what is wrong Differential Revision: D4753827 fbshipit-source-id: 3a92543c648ed7157ec30af7cb1c91a6e6238e33 --- Source/IGListAdapterUpdater.m | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Source/IGListAdapterUpdater.m b/Source/IGListAdapterUpdater.m index 4c4d6cc14..64f2cbeb1 100644 --- a/Source/IGListAdapterUpdater.m +++ b/Source/IGListAdapterUpdater.m @@ -97,7 +97,8 @@ - (void)performReloadDataWithCollectionView:(UICollectionView *)collectionView { NSMutableArray *uniqueObjects = [NSMutableArray new]; for (id object in objects) { id diffIdentifier = [object diffIdentifier]; - if (![identifiers containsObject:diffIdentifier]) { + if (diffIdentifier != nil + && ![identifiers containsObject:diffIdentifier]) { [identifiers addObject:diffIdentifier]; [uniqueObjects addObject:object]; } else { @@ -385,6 +386,8 @@ - (void)performUpdateWithCollectionView:(UICollectionView *)collectionView for (id obj in toObjects) { IGAssert([obj conformsToProtocol:@protocol(IGListDiffable)], @"In order to use IGListAdapterUpdater, object %@ must conform to IGListDiffable", obj); + IGAssert([obj diffIdentifier] != nil, + @"Cannot have a nil diffIdentifier for object %@", obj); } #endif