NSFetchedResultsController调用didChangeObject删除而不是更新

这是代码,我通过魔法logging保存模型:

MagicalRecord.saveWithBlock({ (localContext) -> Void in var localNotification = CDNotification.MR_findFirstByAttribute("notificationID", withValue: notification.notificationID, inContext: localContext) as CDNotification localNotification.readNumber = NSNumber(bool: true) }) 

上面的代码被调用后,删除被调用而不是更新:

 func controller(controller: NSFetchedResultsController, didChangeObject object: AnyObject, atIndexPath indexPath: NSIndexPath, forChangeType type: NSFetchedResultsChangeType, newIndexPath: NSIndexPath) { switch type { case NSFetchedResultsChangeType.Insert: self.tableView.insertRowsAtIndexPaths([newIndexPath], withRowAnimation: .Fade) case NSFetchedResultsChangeType.Update: if let cell = self.tableView.cellForRowAtIndexPath(indexPath){ self.configureCell(cell as TableViewCell, atIndexPath: indexPath, withNotification: object as CDNotification) } self.tableView.reloadRowsAtIndexPaths([indexPath], withRowAnimation: .Fade) case NSFetchedResultsChangeType.Move: self.tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Fade) self.tableView.insertRowsAtIndexPaths([newIndexPath], withRowAnimation: .Fade) case NSFetchedResultsChangeType.Delete: self.tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Fade) default: return } } 

这只会发生,如果我设置提取请求的谓词,例如:

 fetchRequest.predicate = NSPredicate(format:"user == john") 

这里发生的是,而不是NSFetchedResultsChangeUpdate更改事件您所期望的,您将得到一个NSFetchedResultsChangeDelete后跟NSFetchedResultsChangeInsert 。 您也可能会看到NSFetchedResultsChangeMove与源和目标具有相同的indexPath。 这是iOS 9 22380191和其他几个testing版本中的一个已知问题。