Skip handling individual change notifications if we're using a sortSelector and just reload the table afterwards

This commit is contained in:
Christopher Swasey
2012-01-16 11:20:05 -05:00
committed by Blake Watters
parent 8670b233e0
commit 983b7913a2

View File

@@ -511,6 +511,9 @@
- (void)controllerWillChangeContent:(NSFetchedResultsController*)controller {
RKLogTrace(@"Beginning updates for fetchedResultsController (%@). Current section count = %d (resource path: %@)", controller, [[controller sections] count], _resourcePath);
if(_sortSelector) return;
[self.tableView beginUpdates];
_isEmptyBeforeAnimation = [self isEmpty];
}
@@ -520,7 +523,9 @@
atIndex:(NSUInteger)sectionIndex
forChangeType:(NSFetchedResultsChangeType)type {
switch (type) {
if(_sortSelector) return;
switch (type) {
case NSFetchedResultsChangeInsert:
[self.tableView insertSections:[NSIndexSet indexSetWithIndex:sectionIndex]
withRowAnimation:UITableViewRowAnimationFade];
@@ -543,6 +548,8 @@
forChangeType:(NSFetchedResultsChangeType)type
newIndexPath:(NSIndexPath *)newIndexPath {
if(_sortSelector) return;
NSIndexPath* adjIndexPath = [self indexPathForFetchedResultsIndexPath:indexPath];
NSIndexPath* adjNewIndexPath = [self indexPathForFetchedResultsIndexPath:newIndexPath];
@@ -585,8 +592,15 @@
[self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:[self emptyItemIndexPath]]
withRowAnimation:UITableViewRowAnimationFade];
}
[self updateSortedArray];
[self.tableView endUpdates];
if(_sortSelector) {
[self.tableView reloadData];
} else {
[self.tableView endUpdates];
}
[self didFinishLoad];
}