From 69e73065e51f07473d9a74f25e1c857f2390d96a Mon Sep 17 00:00:00 2001 From: Adlai Holler Date: Fri, 19 Aug 2016 12:10:19 -0700 Subject: [PATCH] Avoid accessing itemCountsFromDataSource off-main (#2106) --- AsyncDisplayKit/Details/ASCollectionDataController.mm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/AsyncDisplayKit/Details/ASCollectionDataController.mm b/AsyncDisplayKit/Details/ASCollectionDataController.mm index 170af2b319..71366e0085 100644 --- a/AsyncDisplayKit/Details/ASCollectionDataController.mm +++ b/AsyncDisplayKit/Details/ASCollectionDataController.mm @@ -65,7 +65,10 @@ [self deleteSectionsOfKind:kind atIndexSet:indexSet completion:nil]; // Insert each section - NSUInteger sectionCount = self.itemCountsFromDataSource.size(); + NSUInteger sectionCount = 0; + for (ASIndexedNodeContext *context in contexts) { + sectionCount = MAX(sectionCount, context.indexPath.section + 1); + } NSMutableArray *sections = [NSMutableArray arrayWithCapacity:sectionCount]; for (int i = 0; i < sectionCount; i++) { [sections addObject:[NSMutableArray array]];