mirror of
https://github.com/HackPlan/AsyncDisplayKit.git
synced 2026-03-27 10:34:26 +08:00
Merge pull request #168 from facebook/editing
Fix crash while deleting in multiple sections
This commit is contained in:
@@ -339,10 +339,8 @@ static void *kASDataUpdatingQueueContext = &kASDataUpdatingQueueContext;
|
||||
}
|
||||
|
||||
- (void)deleteRowsAtIndexPaths:(NSArray *)indexPaths {
|
||||
// sort indexPath in revse order to avoid messing up the index when deleting
|
||||
NSArray *sortedIndexPaths = [indexPaths sortedArrayUsingComparator:^NSComparisonResult(NSIndexPath *obj1, NSIndexPath *obj2) {
|
||||
return [obj2 compare:obj1];
|
||||
}];
|
||||
// sort indexPath in order to avoid messing up the index when deleting
|
||||
NSArray *sortedIndexPaths = [indexPaths sortedArrayUsingSelector:@selector(compare:)];
|
||||
|
||||
dispatch_async([ASDataController sizingQueue], ^{
|
||||
[self asyncUpdateDataWithBlock:^{
|
||||
@@ -402,13 +400,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);
|
||||
|
||||
@@ -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<CGSize> &v = _nodeSizes[indexPath.section];
|
||||
v.erase(v.begin() + indexPath.row);
|
||||
}];
|
||||
|
||||
Reference in New Issue
Block a user