diff --git a/CHANGELOG.md b/CHANGELOG.md index 206f6b03..eb3b96ab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,8 @@ The changelog for `IGListKit`. Also see the [releases](https://github.com/instag - Log instead of assert for duplicate diff identifiers to make code testable. [Adam Stern](https://github.com/adamastern) (tbd) +- Fixed crash when using `-[IGListCollectionContext dequeueReusableCellOfClass:withReuseIdentifier:forSectionController:atIndex:]` [Jeremy Lawrence](https://github.com/ziewvater) (tbd) + 3.4.0 ----- diff --git a/Source/IGListAdapter.m b/Source/IGListAdapter.m index f45ad5b8..31288cb9 100644 --- a/Source/IGListAdapter.m +++ b/Source/IGListAdapter.m @@ -94,7 +94,7 @@ // dump old registered section controllers in the case that we are changing collection views or setting for // the first time - _registeredCellClasses = [NSMutableSet new]; + _registeredCellIdentifiers = [NSMutableSet new]; _registeredNibNames = [NSMutableSet new]; _registeredSupplementaryViewIdentifiers = [NSMutableSet new]; _registeredSupplementaryViewNibNames = [NSMutableSet new]; @@ -957,8 +957,8 @@ IGAssert(collectionView != nil, @"Dequeueing cell of class %@ with reuseIdentifier %@ from section controller %@ without a collection view at index %li", NSStringFromClass(cellClass), reuseIdentifier, sectionController, (long)index); NSString *identifier = IGListReusableViewIdentifier(cellClass, nil, nil, reuseIdentifier); NSIndexPath *indexPath = [self indexPathForSectionController:sectionController index:index usePreviousIfInUpdateBlock:NO]; - if (![self.registeredCellClasses containsObject:cellClass]) { - [self.registeredCellClasses addObject:cellClass]; + if (![self.registeredCellIdentifiers containsObject:identifier]) { + [self.registeredCellIdentifiers addObject:identifier]; [collectionView registerClass:cellClass forCellWithReuseIdentifier:identifier]; } return [collectionView dequeueReusableCellWithReuseIdentifier:identifier forIndexPath:indexPath]; diff --git a/Source/Internal/IGListAdapter+DebugDescription.m b/Source/Internal/IGListAdapter+DebugDescription.m index 26cf347c..01d5367f 100644 --- a/Source/Internal/IGListAdapter+DebugDescription.m +++ b/Source/Internal/IGListAdapter+DebugDescription.m @@ -34,9 +34,9 @@ [debug addObject:[NSString stringWithFormat:@"Is prefetching enabled: %@", IGListDebugBOOL(self.collectionView.isPrefetchingEnabled)]]; } - if (self.registeredCellClasses.count > 0) { - [debug addObject:@"Registered cell classes:"]; - [debug addObject:[self.registeredCellClasses description]]; + if (self.registeredCellIdentifiers.count > 0) { + [debug addObject:@"Registered cell identifiers:"]; + [debug addObject:[self.registeredCellIdentifiers description]]; } if (self.registeredNibNames.count > 0) { diff --git a/Source/Internal/IGListAdapterInternal.h b/Source/Internal/IGListAdapterInternal.h index ff8c519f..4497102c 100644 --- a/Source/Internal/IGListAdapterInternal.h +++ b/Source/Internal/IGListAdapterInternal.h @@ -58,7 +58,11 @@ IGListBatchContext @property (nonatomic, assign) BOOL isInUpdateBlock; @property (nonatomic, strong, nullable) IGListSectionMap *previousSectionMap; -@property (nonatomic, strong) NSMutableSet *registeredCellClasses; +/** + Set of cell identifiers registered with the list context. + Identifiers are constructed with the `IGListReusableViewIdentifier` function. + */ +@property (nonatomic, strong) NSMutableSet *registeredCellIdentifiers; @property (nonatomic, strong) NSMutableSet *registeredNibNames; @property (nonatomic, strong) NSMutableSet *registeredSupplementaryViewIdentifiers; @property (nonatomic, strong) NSMutableSet *registeredSupplementaryViewNibNames; diff --git a/Tests/IGListAdapterTests.m b/Tests/IGListAdapterTests.m index f3bd7536..273ba858 100644 --- a/Tests/IGListAdapterTests.m +++ b/Tests/IGListAdapterTests.m @@ -141,7 +141,7 @@ XCTAssertEqualObjects(identifier, @"UICollectionViewCell"); } -- (void)test_whenQueryingReusableIdentifierWithGivenIdentifier_tahtIdentifierEqualsGivenIdentifierAndClassName { +- (void)test_whenQueryingReusableIdentifierWithGivenIdentifier_thatIdentifierEqualsGivenIdentifierAndClassName { NSString *identifier = IGListReusableViewIdentifier(UICollectionViewCell.class, nil, nil, @"MyCoolID"); XCTAssertEqualObjects(identifier, @"MyCoolIDUICollectionViewCell"); }