Skip to content

Commit

Permalink
Add asserts to IGListAdapter
Browse files Browse the repository at this point in the history
Summary:
Fix #91
Closes #108

Differential Revision: D4063183

Pulled By: rnystrom

fbshipit-source-id: 8ff4a5ac3bf7418cb968093e9f87b7fc55bc2fe1
  • Loading branch information
Bofei Zhu authored and Facebook Github Bot committed Oct 22, 2016
1 parent adbb21f commit a01e995
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Source/IGListAdapter.m
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,7 @@ - (__kindof UICollectionViewCell *)dequeueReusableCellOfClass:(Class)cellClass
IGAssertMainThread();
IGParameterAssert(sectionController != nil);
IGParameterAssert(cellClass != nil);
IGParameterAssert(index >= 0);
UICollectionView *collectionView = self.collectionView;
IGAssert(collectionView != nil, @"Reloading adapter without a collection view.");
NSString *identifier = IGListReusableViewIdentifier(cellClass, nil, nil);
Expand All @@ -731,7 +732,9 @@ - (UICollectionViewCell *)dequeueReusableCellWithNibName:(NSString *)nibName
forSectionController:(IGListSectionController<IGListSectionType> *)sectionController
atIndex:(NSInteger)index {
IGAssertMainThread();
IGParameterAssert(nibName != nil);
IGParameterAssert(sectionController != nil);
IGParameterAssert(index >= 0);
UICollectionView *collectionView = self.collectionView;
IGAssert(collectionView != nil, @"Reloading adapter without a collection view.");
NSIndexPath *indexPath = [self indexPathForSectionController:sectionController index:index];
Expand All @@ -748,6 +751,10 @@ - (__kindof UICollectionReusableView *)dequeueReusableSupplementaryViewOfKind:(N
class:(Class)viewClass
atIndex:(NSInteger)index {
IGAssertMainThread();
IGParameterAssert(elementKind.length > 0);
IGParameterAssert(sectionController != nil);
IGParameterAssert(viewClass != nil);
IGParameterAssert(index >= 0);
UICollectionView *collectionView = self.collectionView;
IGAssert(collectionView != nil, @"Reloading adapter without a collection view.");
NSString *identifier = IGListReusableViewIdentifier(viewClass, nil, elementKind);
Expand Down

0 comments on commit a01e995

Please sign in to comment.