diff --git a/AsyncDisplayKit/Details/ASDataController.mm b/AsyncDisplayKit/Details/ASDataController.mm index b540c9c683..d4383fa06e 100644 --- a/AsyncDisplayKit/Details/ASDataController.mm +++ b/AsyncDisplayKit/Details/ASDataController.mm @@ -402,13 +402,7 @@ static void *kASDataUpdatingQueueContext = &kASDataUpdatingQueueContext; [self syncUpdateDataWithBlock:^{ NSArray *indexPaths = ASIndexPathsForMultidimensionalArray(_nodes); - - // sort indexPath in reverse order to avoid messing up the index when inserting in several batches - NSArray *sortedIndexPaths = [indexPaths sortedArrayUsingComparator:^NSComparisonResult(NSIndexPath *obj1, NSIndexPath *obj2) { - return [obj2 compare:obj1]; - }]; - - DELETE_NODES(_nodes, sortedIndexPaths); + DELETE_NODES(_nodes, indexPaths); NSMutableIndexSet *indexSet = [[NSMutableIndexSet alloc] initWithIndexesInRange:NSMakeRange(0, _nodes.count)]; DELETE_SECTIONS(_nodes, indexSet); diff --git a/AsyncDisplayKit/Details/ASFlowLayoutController.mm b/AsyncDisplayKit/Details/ASFlowLayoutController.mm index f2e3af3b97..7101a1103b 100644 --- a/AsyncDisplayKit/Details/ASFlowLayoutController.mm +++ b/AsyncDisplayKit/Details/ASFlowLayoutController.mm @@ -47,7 +47,7 @@ static const CGFloat kASFlowLayoutControllerRefreshingThreshold = 0.3; } - (void)deleteNodesAtIndexPaths:(NSArray *)indexPaths { - [indexPaths enumerateObjectsUsingBlock:^(NSIndexPath *indexPath, NSUInteger idx, BOOL *stop) { + [indexPaths enumerateObjectsWithOptions:NSEnumerationReverse usingBlock:^(NSIndexPath *indexPath, NSUInteger idx, BOOL *stop) { std::vector &v = _nodeSizes[indexPath.section]; v.erase(v.begin() + indexPath.row); }];