mirror of
https://github.com/Instagram/IGListKit
synced 2026-05-24 09:48:21 +00:00
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
This commit is contained in:
parent
039e77e359
commit
aa2361f449
4 changed files with 10 additions and 13 deletions
|
|
@ -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
|
||||
-----
|
||||
|
||||
|
|
|
|||
|
|
@ -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];
|
||||
|
|
|
|||
|
|
@ -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 ()
|
||||
|
|
|
|||
|
|
@ -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];
|
||||
|
|
|
|||
Loading…
Reference in a new issue