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
This commit is contained in:
Ryan Nystrom 2017-06-22 13:02:00 -07:00 committed by Facebook Github Bot
parent 95367bb6a4
commit d0253b705a

View file

@ -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;
}