From aa2361f449e62a917633f6f706bed4c9b4d3818e Mon Sep 17 00:00:00 2001 From: trungducc Date: Tue, 30 Oct 2018 13:41:34 -0700 Subject: [PATCH] Remove nibName argument from IGListReusableViewIdentifier #trivial (#1241) Summary: Issue fixed: #1223 - [x] All tests pass. Demo project builds and runs. - [x] I added tests, an experiment, or detailed why my change isn't tested. - [x] I added an entry to the `CHANGELOG.md` for any breaking changes, enhancements, or bug fixes. - [x] I have reviewed the [contributing guide](https://github.com/Instagram/IGListKit/blob/master/.github/CONTRIBUTING.md) Pull Request resolved: https://github.com/Instagram/IGListKit/pull/1241 Differential Revision: D12838898 Pulled By: rnystrom fbshipit-source-id: af47550dd320fb0e813e8ae22bc7051c2460a05d --- CHANGELOG.md | 3 +++ Source/IGListAdapter.m | 4 ++-- Source/Internal/IGListAdapterInternal.h | 4 ++-- Tests/IGListAdapterTests.m | 12 +++--------- 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b339c5b..bf448613 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,8 +32,11 @@ 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) +- Removed `nibName` argument from `IGListReusableViewIdentifier`. [Trung Duc](https://github.com/trungducc) [(#1223)](https://github.com/Instagram/IGListKit/issues/1223) + - 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 31288cb9..b32873c7 100644 --- a/Source/IGListAdapter.m +++ b/Source/IGListAdapter.m @@ -955,7 +955,7 @@ IGParameterAssert(index >= 0); UICollectionView *collectionView = self.collectionView; 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); + NSString *identifier = IGListReusableViewIdentifier(cellClass, nil, reuseIdentifier); NSIndexPath *indexPath = [self indexPathForSectionController:sectionController index:index usePreviousIfInUpdateBlock:NO]; if (![self.registeredCellIdentifiers containsObject:identifier]) { [self.registeredCellIdentifiers addObject:identifier]; @@ -1012,7 +1012,7 @@ IGParameterAssert(index >= 0); UICollectionView *collectionView = self.collectionView; IGAssert(collectionView != nil, @"Dequeueing cell of class %@ from section controller %@ without a collection view at index %li with supplementary view %@", NSStringFromClass(viewClass), sectionController, (long)index, elementKind); - NSString *identifier = IGListReusableViewIdentifier(viewClass, nil, elementKind, nil); + NSString *identifier = IGListReusableViewIdentifier(viewClass, elementKind, nil); NSIndexPath *indexPath = [self indexPathForSectionController:sectionController index:index usePreviousIfInUpdateBlock:NO]; if (![self.registeredSupplementaryViewIdentifiers containsObject:identifier]) { [self.registeredSupplementaryViewIdentifiers addObject:identifier]; diff --git a/Source/Internal/IGListAdapterInternal.h b/Source/Internal/IGListAdapterInternal.h index 4497102c..176ee881 100644 --- a/Source/Internal/IGListAdapterInternal.h +++ b/Source/Internal/IGListAdapterInternal.h @@ -18,8 +18,8 @@ NS_ASSUME_NONNULL_BEGIN /// Generate a string representation of a reusable view class when registering with a UICollectionView. -NS_INLINE NSString *IGListReusableViewIdentifier(Class viewClass, NSString * _Nullable nibName, NSString * _Nullable kind, NSString * _Nullable givenReuseIdentifier) { - return [NSString stringWithFormat:@"%@%@%@%@", kind ?: @"", nibName ?: @"", givenReuseIdentifier ?: @"", NSStringFromClass(viewClass)]; +NS_INLINE NSString *IGListReusableViewIdentifier(Class viewClass, NSString * _Nullable kind, NSString * _Nullable givenReuseIdentifier) { + return [NSString stringWithFormat:@"%@%@%@", kind ?: @"", givenReuseIdentifier ?: @"", NSStringFromClass(viewClass)]; } @interface IGListAdapter () diff --git a/Tests/IGListAdapterTests.m b/Tests/IGListAdapterTests.m index 42a969c7..d40d5119 100644 --- a/Tests/IGListAdapterTests.m +++ b/Tests/IGListAdapterTests.m @@ -137,26 +137,20 @@ } - (void)test_whenQueryingReusableIdentifier_thatIdentifierEqualsClassName { - NSString *identifier = IGListReusableViewIdentifier(UICollectionViewCell.class, nil, nil, nil); + NSString *identifier = IGListReusableViewIdentifier(UICollectionViewCell.class, nil, nil); XCTAssertEqualObjects(identifier, @"UICollectionViewCell"); } - (void)test_whenQueryingReusableIdentifierWithGivenIdentifier_thatIdentifierEqualsGivenIdentifierAndClassName { - NSString *identifier = IGListReusableViewIdentifier(UICollectionViewCell.class, nil, nil, @"MyCoolID"); + NSString *identifier = IGListReusableViewIdentifier(UICollectionViewCell.class, nil, @"MyCoolID"); XCTAssertEqualObjects(identifier, @"MyCoolIDUICollectionViewCell"); } - (void)test_whenQueryingReusableIdentifier_thatIdentifierEqualsClassNameAndSupplimentaryKind { - NSString *identifier = IGListReusableViewIdentifier(UICollectionViewCell.class, nil, UICollectionElementKindSectionFooter, nil); + NSString *identifier = IGListReusableViewIdentifier(UICollectionViewCell.class, UICollectionElementKindSectionFooter, nil); XCTAssertEqualObjects(identifier, @"UICollectionElementKindSectionFooterUICollectionViewCell"); } -- (void)test_whenQueryingReusableIdentifier_thatIdentifierEqualsClassNameAndNibName { - NSString *nibName = @"IGNibName"; - NSString *identifier = IGListReusableViewIdentifier(UICollectionViewCell.class, nibName, nil, nil); - XCTAssertEqualObjects(identifier, @"IGNibNameUICollectionViewCell"); -} - - (void)test_whenDequeueingTwoCellsOfTheSameClassWithDifferentReuseIdentifiers_thatBothReuseIdentifiersReturnCells { self.dataSource.objects = @[@1, @2]; [self.adapter reloadDataWithCompletion:nil];