Better error message if a display node is created in layoutSpecThatFits: and deallocated before it was added to a subnode

This commit is contained in:
Michael Schneider 2016-12-01 07:03:39 -08:00
parent b075aa2851
commit 66acd69e22

View File

@ -233,7 +233,7 @@ static inline std::vector<NSUInteger> findNodesInLayoutAtIndexesWithFilteredNode
if (idx > lastIndex) { break; }
if (idx >= firstIndex && [indexes containsIndex:idx]) {
ASDisplayNode *node = (ASDisplayNode *)sublayout.layoutElement;
ASDisplayNodeCAssert(node, @"A flattened layout must consist exclusively of node sublayouts");
ASDisplayNodeCAssert(node, @"ASDisplayNode was deallocated before it was added to a subnode. It's likely the case that you use automatically manages subnodes and allocate a ASDisplayNode in layoutSpecThatFits: and don't have any strong reference to it.");
// Ignore the odd case in which a non-node sublayout is accessed and the type cast fails
if (node != nil) {
BOOL notFiltered = (filteredNodes == nil || [filteredNodes indexOfObjectIdenticalTo:node] == NSNotFound);