Last active
September 24, 2015 12:33
-
-
Save dreamolight/157266c615d4a226e772 to your computer and use it in GitHub Desktop.
Core Data bug on iOS8 & iOS9 build via Xcode7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)controller:(NSFetchedResultsController *)controller | |
didChangeObject:(id)anObject | |
atIndexPath:(NSIndexPath *)indexPath | |
forChangeType:(NSFetchedResultsChangeType)type | |
newIndexPath:(NSIndexPath *)newIndexPath | |
{ | |
if (![self isViewLoaded]) return; | |
switch(type) | |
{ | |
case NSFetchedResultsChangeInsert: | |
[self.tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:newIndexPath] | |
withRowAnimation:UITableViewRowAnimationFade]; | |
break; | |
case NSFetchedResultsChangeDelete: | |
[self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] | |
withRowAnimation:UITableViewRowAnimationFade]; | |
break; | |
case NSFetchedResultsChangeUpdate:{ | |
MyChatCell *cell = (MyChatCell *)[self.tableView cellForRowAtIndexPath:indexPath]; | |
CoreDataObject *cdo = [[self fetchedResultsController] objectAtIndexPath:indexPath]; | |
// update the cell with the content: cdo | |
[cell updateContent:cdo]; | |
} | |
break; | |
case NSFetchedResultsChangeMove: | |
if (indexPath.row!=newIndexPath.row || indexPath.section!=newIndexPath.section){ | |
[self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] | |
withRowAnimation:UITableViewRowAnimationFade]; | |
[self.tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:newIndexPath] | |
withRowAnimation:UITableViewRowAnimationFade]; | |
}else{ | |
[self.tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone]; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment