Skip to content

Commit

Permalink
Copy sublayers to avoid NSFastEnumerationMutation exception
Browse files Browse the repository at this point in the history
  • Loading branch information
Adlai-Holler committed Mar 24, 2016
1 parent 4ffaebc commit a90a83b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion AsyncDisplayKit/ASDisplayNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ NS_ASSUME_NONNULL_BEGIN
/**
* @abstract The receiver's immediate subnodes.
*/
@property (nonatomic, readonly, strong) NSArray<ASDisplayNode *> *subnodes;
@property (nonatomic, readonly, copy) NSArray<ASDisplayNode *> *subnodes;

/**
* @abstract The receiver's supernode.
Expand Down
4 changes: 3 additions & 1 deletion AsyncDisplayKit/ASDisplayNodeExtras.mm
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ extern void ASDisplayNodePerformBlockOnEveryNode(CALayer *layer, ASDisplayNode *
}

if (layer) {
for (CALayer *sublayer in [layer sublayers]) {
/// NOTE: The docs say `sublayers` returns a copy, but it does not.
/// See: http://stackoverflow.com/questions/14854480/collection-calayerarray-0x1ed8faa0-was-mutated-while-being-enumerated
for (CALayer *sublayer in [[layer sublayers] copy]) {
ASDisplayNodePerformBlockOnEveryNode(sublayer, nil, block);
}
} else if (node) {
Expand Down

0 comments on commit a90a83b

Please sign in to comment.