Skip to content

Commit

Permalink
Avoid triggering main thread assertions in collection/table dealloc #…
Browse files Browse the repository at this point in the history
…trivial (#803)

* Avoid triggering main thread assertions in ASCollectionNode/ASTableNode dealloc

* Put it back
  • Loading branch information
Adlai-Holler committed Feb 13, 2018
1 parent e2478fc commit 8b43173
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
9 changes: 7 additions & 2 deletions Source/ASCollectionNode.mm
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,17 @@ - (instancetype)initWithFrame:(CGRect)frame collectionViewLayout:(UICollectionVi
return self;
}

#if ASDISPLAYNODE_ASSERTIONS_ENABLED
- (void)dealloc
{
if ([self isNodeLoaded]) {
ASDisplayNodeAssert(self.view.superview == nil, @"Node's view should be removed from hierarchy.");
if (self.nodeLoaded) {
__weak UIView *view = self.view;
ASPerformBlockOnMainThread(^{
ASDisplayNodeCAssertNil(view.superview, @"Node's view should be removed from hierarchy.");
});
}
}
#endif

#pragma mark ASDisplayNode

Expand Down
9 changes: 7 additions & 2 deletions Source/ASTableNode.mm
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,17 @@ - (instancetype)init
return [self initWithStyle:UITableViewStylePlain];
}

#if ASDISPLAYNODE_ASSERTIONS_ENABLED
- (void)dealloc
{
if ([self isNodeLoaded]) {
ASDisplayNodeAssert(self.view.superview == nil, @"Node's view should be removed from hierarchy.");
if (self.nodeLoaded) {
__weak UIView *view = self.view;
ASPerformBlockOnMainThread(^{
ASDisplayNodeCAssertNil(view.superview, @"Node's view should be removed from hierarchy.");
});
}
}
#endif

#pragma mark ASDisplayNode

Expand Down

0 comments on commit 8b43173

Please sign in to comment.