From b40c1dbfc334f5e1bfc52ea6a5d6d69b93023819 Mon Sep 17 00:00:00 2001 From: Ethan Nagel Date: Wed, 22 Apr 2015 13:57:25 -0700 Subject: [PATCH 1/2] on ASDataController dealloc, ensure that loaded Cell nodes are not in the TableViewCell. For reasons I don't fully understand, this avoids a retain cycle with the currently displayed cells. --- AsyncDisplayKit/Details/ASDataController.mm | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/AsyncDisplayKit/Details/ASDataController.mm b/AsyncDisplayKit/Details/ASDataController.mm index ed70155727..54cc4eed84 100644 --- a/AsyncDisplayKit/Details/ASDataController.mm +++ b/AsyncDisplayKit/Details/ASDataController.mm @@ -508,4 +508,17 @@ static void *kASSizingQueueContext = &kASSizingQueueContext; return ASFindElementsInMultidimensionalArrayAtIndexPaths(_nodes, [indexPaths sortedArrayUsingSelector:@selector(compare:)]); } +#pragma mark - Dealloc + +- (void)dealloc { + ASDisplayNodeAssertMainThread(); + [_nodes enumerateObjectsUsingBlock:^(NSMutableArray *section, NSUInteger sectionIndex, BOOL *stop) { + [section enumerateObjectsUsingBlock:^(ASCellNode *node, NSUInteger rowIndex, BOOL *stop) { + if (node.isNodeLoaded && node.view.superview) { + [node.view removeFromSuperview]; + } + }]; + }]; +} + @end From 38f08c9bd8ac1ac521f42ece9ed0f4167099c36f Mon Sep 17 00:00:00 2001 From: Ethan Nagel Date: Sun, 3 May 2015 21:45:33 -0700 Subject: [PATCH 2/2] support layers as well as views when doing ASDisplayCell cleanup (in case we add support for layer-backed ASDisplayCells in the future.) --- AsyncDisplayKit/Details/ASDataController.mm | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/AsyncDisplayKit/Details/ASDataController.mm b/AsyncDisplayKit/Details/ASDataController.mm index 54cc4eed84..85f6e5126b 100644 --- a/AsyncDisplayKit/Details/ASDataController.mm +++ b/AsyncDisplayKit/Details/ASDataController.mm @@ -514,8 +514,12 @@ static void *kASSizingQueueContext = &kASSizingQueueContext; ASDisplayNodeAssertMainThread(); [_nodes enumerateObjectsUsingBlock:^(NSMutableArray *section, NSUInteger sectionIndex, BOOL *stop) { [section enumerateObjectsUsingBlock:^(ASCellNode *node, NSUInteger rowIndex, BOOL *stop) { - if (node.isNodeLoaded && node.view.superview) { - [node.view removeFromSuperview]; + if (node.isNodeLoaded) { + if (node.layerBacked) { + [node.layer removeFromSuperlayer]; + } else { + [node.view removeFromSuperview]; + } } }]; }];