From a01e9954e3499a74c565516622ffa2f9e8348cab Mon Sep 17 00:00:00 2001 From: Bofei Zhu Date: Fri, 21 Oct 2016 19:46:42 -0700 Subject: [PATCH] Add asserts to IGListAdapter Summary: Fix #91 Closes https://github.com/Instagram/IGListKit/pull/108 Differential Revision: D4063183 Pulled By: rnystrom fbshipit-source-id: 8ff4a5ac3bf7418cb968093e9f87b7fc55bc2fe1 --- Source/IGListAdapter.m | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Source/IGListAdapter.m b/Source/IGListAdapter.m index 68ce3138..e35ad6b6 100644 --- a/Source/IGListAdapter.m +++ b/Source/IGListAdapter.m @@ -715,6 +715,7 @@ 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); @@ -731,7 +732,9 @@ forSectionController:(IGListSectionController *)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]; @@ -748,6 +751,10 @@ 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);