From d0253b705ab87c99a4de209436fbc66733287994 Mon Sep 17 00:00:00 2001 From: Ryan Nystrom Date: Thu, 22 Jun 2017 13:02:00 -0700 Subject: [PATCH] Don't assert indexForCell: API when cell isn't visible Summary: Noticed this randomly debugging. Say you have a completion block that finishes after some async task happens. If you scroll the cell off screen it will return `nil` for `-[UICollectionView indexPathForCell:]`, and the assert will fail (unless the SC is at 0). Quiet some asserts. Closes https://github.com/Instagram/IGListKit/pull/824 Differential Revision: D5303432 Pulled By: rnystrom fbshipit-source-id: 64432c43f46d33ce052e6f4fedc094c1fc1f04e1 --- Source/IGListAdapter.m | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/IGListAdapter.m b/Source/IGListAdapter.m index 42e0d3c1..11f7600d 100644 --- a/Source/IGListAdapter.m +++ b/Source/IGListAdapter.m @@ -731,7 +731,8 @@ IGParameterAssert(cell != nil); IGParameterAssert(sectionController != nil); NSIndexPath *indexPath = [self.collectionView indexPathForCell:cell]; - IGAssert(indexPath.section == [self sectionForSectionController:sectionController], + IGAssert(indexPath == nil + || indexPath.section == [self sectionForSectionController:sectionController], @"Requesting a cell from another section controller is not allowed."); return indexPath != nil ? indexPath.item : NSNotFound; }