Allow section-indexpaths in collection & table validation (#2727)

This commit is contained in:
Adlai Holler
2016-12-07 13:36:15 -08:00
committed by GitHub
parent a6b2166244
commit 7de2decdcb
2 changed files with 6 additions and 2 deletions

View File

@@ -642,7 +642,9 @@ static NSString * const kCellReuseIdentifier = @"_ASCollectionViewCell";
return nil;
}
if (indexPath.item >= [self numberOfItemsInSection:section]) {
NSInteger item = indexPath.item;
// item == NSNotFound means e.g. "scroll to this section" and is acceptable
if (item != NSNotFound && item >= [self numberOfItemsInSection:section]) {
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]);
return nil;
}

View File

@@ -579,7 +579,9 @@ static NSString * const kCellReuseIdentifier = @"_ASTableViewCell";
return nil;
}
if (indexPath.item >= [self numberOfRowsInSection:section]) {
NSInteger item = indexPath.item;
// item == NSNotFound means e.g. "scroll to this section" and is acceptable
if (item != NSNotFound && item >= [self numberOfRowsInSection:section]) {
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]);
return nil;
}