Это код, я сохраняю модель через Magical Record:
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")