From 8eb25e737b98bc520c4bbc5a53c51a05e935cabb Mon Sep 17 00:00:00 2001 From: Adlai Holler Date: Tue, 12 Jul 2016 15:17:57 -0700 Subject: [PATCH] [ASCollectionDataController] Use block-based enumeration with dictionaries --- .../Details/ASCollectionDataController.mm | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/AsyncDisplayKit/Details/ASCollectionDataController.mm b/AsyncDisplayKit/Details/ASCollectionDataController.mm index b0f033d017..f3bcede28c 100644 --- a/AsyncDisplayKit/Details/ASCollectionDataController.mm +++ b/AsyncDisplayKit/Details/ASCollectionDataController.mm @@ -88,8 +88,7 @@ - (void)willInsertSections:(NSIndexSet *)sections { - for (NSString *kind in _pendingContexts) { - NSMutableArray *contexts = _pendingContexts[kind]; + [_pendingContexts enumerateKeysAndObjectsUsingBlock:^(NSString * _Nonnull kind, NSMutableArray * _Nonnull contexts, BOOL * _Nonnull stop) { NSMutableArray *sectionArray = [NSMutableArray arrayWithCapacity:sections.count]; for (NSUInteger i = 0; i < sections.count; i++) { [sectionArray addObject:[NSMutableArray array]]; @@ -99,7 +98,7 @@ [self batchLayoutNodesFromContexts:contexts ofKind:kind completion:^(NSArray *nodes, NSArray *indexPaths) { [self insertNodes:nodes ofKind:kind atIndexPaths:indexPaths completion:nil]; }]; - } + }]; [_pendingContexts removeAllObjects]; } @@ -145,13 +144,12 @@ - (void)willInsertRowsAtIndexPaths:(NSArray *)indexPaths { - for (NSString *kind in _pendingContexts) { - NSMutableArray *contexts = _pendingContexts[kind]; - + [_pendingContexts enumerateKeysAndObjectsUsingBlock:^(NSString * _Nonnull kind, NSMutableArray * _Nonnull contexts, BOOL * _Nonnull stop) { [self batchLayoutNodesFromContexts:contexts ofKind:kind completion:^(NSArray *nodes, NSArray *indexPaths) { [self insertNodes:nodes ofKind:kind atIndexPaths:indexPaths completion:nil]; }]; - } + }]; + [_pendingContexts removeAllObjects]; }