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 Oct 4, 2016
1 parent 0a2e35a commit 67045c0
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 @@ -959,7 +959,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 @@ -1125,10 +1125,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 67045c0

Please sign in to comment.