One more critical update integrity fix

This commit is contained in:
Adlai Holler
2016-06-23 17:28:22 -07:00
parent 681876bd59
commit d8d2524b89
3 changed files with 6 additions and 6 deletions

View File

@@ -17,8 +17,8 @@
/// Returns all the item indexes from the given index paths that are in the given section. /// Returns all the item indexes from the given index paths that are in the given section.
+ (NSIndexSet *)as_indexSetFromIndexPaths:(NSArray<NSIndexPath *> *)indexPaths inSection:(NSUInteger)section; + (NSIndexSet *)as_indexSetFromIndexPaths:(NSArray<NSIndexPath *> *)indexPaths inSection:(NSUInteger)section;
/// If you've got an old index, and you insert items using this index set, this returns the new index. /// If you've got an old index, and you insert items using this index set, this returns the change to get to the new index.
- (NSUInteger)as_indexByInsertingItemsBelowIndex:(NSUInteger)index; - (NSUInteger)as_indexChangeByInsertingItemsBelowIndex:(NSUInteger)index;
- (NSString *)as_smallDescription; - (NSString *)as_smallDescription;

View File

@@ -46,7 +46,7 @@
return result; return result;
} }
- (NSUInteger)as_indexByInsertingItemsBelowIndex:(NSUInteger)index - (NSUInteger)as_indexChangeByInsertingItemsBelowIndex:(NSUInteger)index
{ {
__block NSUInteger newIndex = index; __block NSUInteger newIndex = index;
[self enumerateIndexesUsingBlock:^(NSUInteger idx, BOOL * _Nonnull stop) { [self enumerateIndexesUsingBlock:^(NSUInteger idx, BOOL * _Nonnull stop) {
@@ -56,7 +56,7 @@
*stop = YES; *stop = YES;
} }
}]; }];
return newIndex; return newIndex - index;
} }
- (NSString *)as_smallDescription - (NSString *)as_smallDescription

View File

@@ -139,7 +139,7 @@ NSString *NSStringFromASHierarchyChangeType(_ASHierarchyChangeType changeType)
} }
NSUInteger newIndex = oldSection - [_deletedSections countOfIndexesInRange:NSMakeRange(0, oldSection)]; NSUInteger newIndex = oldSection - [_deletedSections countOfIndexesInRange:NSMakeRange(0, oldSection)];
newIndex = [_insertedSections as_indexByInsertingItemsBelowIndex:newIndex]; newIndex += [_insertedSections as_indexChangeByInsertingItemsBelowIndex:newIndex];
return newIndex; return newIndex;
} }
@@ -276,7 +276,7 @@ NSString *NSStringFromASHierarchyChangeType(_ASHierarchyChangeType changeType)
item -= [indicesDeletedInSection countOfIndexesInRange:NSMakeRange(0, item)]; item -= [indicesDeletedInSection countOfIndexesInRange:NSMakeRange(0, item)];
// Update row number based on insertions that are above the current row in the future section // Update row number based on insertions that are above the current row in the future section
NSIndexSet *indicesInsertedInSection = insertedIndexPathsMap[@(section)]; NSIndexSet *indicesInsertedInSection = insertedIndexPathsMap[@(section)];
item = [indicesInsertedInSection as_indexByInsertingItemsBelowIndex:item]; item += [indicesInsertedInSection as_indexChangeByInsertingItemsBelowIndex:item];
//TODO: reuse the old indexPath object if section and row aren't changed //TODO: reuse the old indexPath object if section and row aren't changed
NSIndexPath *newIndexPath = [NSIndexPath indexPathForItem:item inSection:section]; NSIndexPath *newIndexPath = [NSIndexPath indexPathForItem:item inSection:section];