From b40c1dbfc334f5e1bfc52ea6a5d6d69b93023819 Mon Sep 17 00:00:00 2001 From: Ethan Nagel Date: Wed, 22 Apr 2015 13:57:25 -0700 Subject: [PATCH] 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