Skip to content

Commit

Permalink
Assert nil diff identifier, remove if nil
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Ryan Nystrom authored and facebook-github-bot committed Mar 22, 2017
1 parent 353d90f commit af984ca
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Source/IGListAdapterUpdater.m
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ - (void)performReloadDataWithCollectionView:(UICollectionView *)collectionView {
NSMutableArray *uniqueObjects = [NSMutableArray new];
for (id<IGListDiffable> object in objects) {
id diffIdentifier = [object diffIdentifier];
if (![identifiers containsObject:diffIdentifier]) {
if (diffIdentifier != nil
&& ![identifiers containsObject:diffIdentifier]) {
[identifiers addObject:diffIdentifier];
[uniqueObjects addObject:object];
} else {
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit af984ca

Please sign in to comment.