Prevent deallocation of asyncDataSource and asyncDelegate in ASCollectionView and ASTableView

Grab a strong reference for asyncDataSource and asyncDelegate in ASCollectionView and ASTableView before executing the range update to be sure they are not going away while executing the range update. This can happen in range updates while going back in the view controller hierarchy
This commit is contained in:
Michael Schneider
2016-03-22 08:09:59 -07:00
parent fbe87cde4b
commit 3668f45286
4 changed files with 48 additions and 4 deletions

View File

@@ -1139,7 +1139,14 @@ static NSString * const kCellReuseIdentifier = @"_ASCollectionViewCell";
// Updating the visible node index paths only for not range managed nodes. Range managed nodes will get their
// their update in the layout pass
if (![node supportsRangeManagedInterfaceState]) {
[_rangeController visibleNodeIndexPathsDidChangeWithScrollDirection:self.scrollDirection];
// Grab a strong reference for data source and delegate to be sure they are not going away while executing
// the range update. This can happen in range updates while going back in the view controller hierarchy
__block id<ASCollectionDataSource> asyncDataSource = _asyncDataSource;
__block id<ASCollectionDelegate> asyncDelegate = _asyncDelegate;
[_rangeController scheduleRangeUpdateCompletion:^{
asyncDataSource = nil;
asyncDelegate = nil;
}];
}
}