Skip to content
This repository was archived by the owner on Feb 2, 2023. It is now read-only.

Commit 8e0b102

Browse files
Adlai Hollergarrettmoon
authored andcommitted
Allow section-indexpaths in collection & table validation (#2727)
1 parent 1f00231 commit 8e0b102

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

AsyncDisplayKit/ASCollectionView.mm

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,9 @@ - (nullable NSIndexPath *)validateIndexPath:(nullable NSIndexPath *)indexPath
642642
return nil;
643643
}
644644

645-
if (indexPath.item >= [self numberOfItemsInSection:section]) {
645+
NSInteger item = indexPath.item;
646+
// item == NSNotFound means e.g. "scroll to this section" and is acceptable
647+
if (item != NSNotFound && item >= [self numberOfItemsInSection:section]) {
646648
ASDisplayNodeFailAssert(@"Collection view index path has invalid item %lu in section %lu, item count = %lu", (unsigned long)indexPath.item, (unsigned long)section, (unsigned long)[self numberOfItemsInSection:section]);
647649
return nil;
648650
}

AsyncDisplayKit/ASTableView.mm

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,9 @@ - (nullable NSIndexPath *)validateIndexPath:(nullable NSIndexPath *)indexPath
579579
return nil;
580580
}
581581

582-
if (indexPath.item >= [self numberOfRowsInSection:section]) {
582+
NSInteger item = indexPath.item;
583+
// item == NSNotFound means e.g. "scroll to this section" and is acceptable
584+
if (item != NSNotFound && item >= [self numberOfRowsInSection:section]) {
583585
ASDisplayNodeFailAssert(@"Table view index path has invalid item %lu in section %lu, item count = %lu", (unsigned long)indexPath.item, (unsigned long)section, (unsigned long)[self numberOfRowsInSection:section]);
584586
return nil;
585587
}

0 commit comments

Comments
 (0)