Copy sublayers to avoid NSFastEnumerationMutation exception

This commit is contained in:
Adlai Holler 2016-03-23 21:57:23 -07:00
parent 4ffaebc93b
commit a90a83b607
2 changed files with 4 additions and 2 deletions

View File

@ -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.

View File

@ -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) {