diff --git a/Source/DATASource+NSFetchedResultsControllerDelegate.swift b/Source/DATASource+NSFetchedResultsControllerDelegate.swift index 5dfea81..3c3576b 100644 --- a/Source/DATASource+NSFetchedResultsControllerDelegate.swift +++ b/Source/DATASource+NSFetchedResultsControllerDelegate.swift @@ -66,6 +66,9 @@ extension DATASource: NSFetchedResultsControllerDelegate { break case .update: if let newIndexPath = newIndexPath { + if let indexPath = indexPath, indexPath != newIndexPath { + fallthrough + } if tableView.indexPathsForVisibleRows?.firstIndex(of: newIndexPath) != nil { if let cell = tableView.cellForRow(at: newIndexPath) { self.configure(cell, indexPath: newIndexPath) @@ -79,24 +82,11 @@ extension DATASource: NSFetchedResultsControllerDelegate { break case .move: if let indexPath = indexPath, let newIndexPath = newIndexPath { - // Workaround: Updating a UICollectionView element sometimes will trigger a .Move change - // where both indexPaths are the same, as a workaround if this happens, DATASource - // will treat this change as an .Update - if indexPath == newIndexPath { - if let cell = tableView.cellForRow(at: newIndexPath) { - self.configure(cell, indexPath: newIndexPath) - } - - if let anObject = anObject as? NSManagedObject { - self.delegate?.dataSource?(self, didUpdateObject: anObject, atIndexPath: newIndexPath) - } - } else { - tableView.deleteRows(at: [indexPath], with: rowAnimationType) - tableView.insertRows(at: [newIndexPath], with: rowAnimationType) + tableView.deleteRows(at: [indexPath], with: rowAnimationType) + tableView.insertRows(at: [newIndexPath], with: rowAnimationType) - if let anObject = anObject as? NSManagedObject { - self.delegate?.dataSource?(self, didMoveObject: anObject, fromIndexPath: indexPath, toIndexPath: newIndexPath) - } + if let anObject = anObject as? NSManagedObject { + self.delegate?.dataSource?(self, didMoveObject: anObject, fromIndexPath: indexPath, toIndexPath: newIndexPath) } } break