From cf7f78e28a1c100c38c28858a16af9b1bb46a690 Mon Sep 17 00:00:00 2001 From: Yaxuan Wang Date: Wed, 7 Sep 2022 10:53:49 -0700 Subject: [PATCH] Avoid warning at [IGListAdapter visibleObjects] Summary: Almost all of the [warnings](https://fburl.com/scuba/errorreporting_instagram_ios_assertions/s2odhkpd) at `[IGListAdapter visibleObjects]` shown the section index is `9223372036854775807`, which is `NSNotFound`. When the section is `NSNotFound`, there is no need to get object though `[self objectAtSection:section];`, instead we should skip all the operations. Differential Revision: D39294533 fbshipit-source-id: 3e481c76c0a2dd53b219800e590395b067ae2db8 --- Source/IGListKit/IGListAdapter.m | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Source/IGListKit/IGListAdapter.m b/Source/IGListKit/IGListAdapter.m index 72383551..624c40e3 100644 --- a/Source/IGListKit/IGListAdapter.m +++ b/Source/IGListKit/IGListAdapter.m @@ -603,10 +603,12 @@ typedef struct OffsetRange { IGAssert(sectionController != nil, @"Section controller nil for cell %@", cell); if (sectionController != nil) { const NSInteger section = [self sectionForSectionController:sectionController]; - id object = [self objectAtSection:section]; - IGAssert(object != nil, @"Object not found for section controller %@ at section %li", sectionController, (long)section); - if (object != nil) { - [visibleObjects addObject:object]; + if (section != NSNotFound) { + id object = [self objectAtSection:section]; + IGAssert(object != nil, @"Object not found for section controller %@ at section %li", sectionController, (long)section); + if (object != nil) { + [visibleObjects addObject:object]; + } } } }