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

Commit

Permalink
Handle nil node blocks gracefully in production (#2338)
Browse files Browse the repository at this point in the history
  • Loading branch information
Adlai Holler authored and hannahmbanana committed Oct 4, 2016
1 parent adcb75f commit 79a6c66
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion AsyncDisplayKit/ASCollectionView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -965,7 +965,7 @@ - (ASCellNodeBlock)dataController:(ASDataController *)dataController nodeBlockAt
return ^{
__typeof__(self) strongSelf = weakSelf;

ASCellNode *node = block();
ASCellNode *node = (block != nil ? block() : [[ASCellNode alloc] init]);
[node enterHierarchyState:ASHierarchyStateRangeManaged];
if (node.interactionDelegate == nil) {
node.interactionDelegate = strongSelf;
Expand Down
3 changes: 2 additions & 1 deletion AsyncDisplayKit/ASTableView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1140,10 +1140,11 @@ - (ASCellNodeBlock)dataController:(ASDataController *)dataController nodeBlockAt
}

ASCellNodeBlock block = [_asyncDataSource tableView:self nodeBlockForRowAtIndexPath:indexPath];
ASDisplayNodeAssertNotNil(block, @"Invalid block, expected nonnull ASCellNodeBlock");
__weak __typeof__(self) weakSelf = self;
ASCellNodeBlock configuredNodeBlock = ^{
__typeof__(self) strongSelf = weakSelf;
ASCellNode *node = block();
ASCellNode *node = (block != nil ? block() : [[ASCellNode alloc] init]);
[node enterHierarchyState:ASHierarchyStateRangeManaged];
if (node.interactionDelegate == nil) {
node.interactionDelegate = strongSelf;
Expand Down

0 comments on commit 79a6c66

Please sign in to comment.