mirror of
https://github.com/Instagram/IGListKit
synced 2026-05-23 17:28:22 +00:00
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
This commit is contained in:
parent
353d90f397
commit
af984ca81d
1 changed files with 4 additions and 1 deletions
|
|
@ -97,7 +97,8 @@ static NSArray *objectsWithDuplicateIdentifiersRemoved(NSArray<id<IGListDiffable
|
|||
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 {
|
||||
|
|
@ -385,6 +386,8 @@ static NSUInteger IGListIdentifierHash(const void *item, NSUInteger (*size)(cons
|
|||
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
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue