NSFetchedResultsChangeUpdate fired instead of NSFetchedResultsChangeDelete

心已入冬 提交于 2019-12-05 03:28:33

Of course changeUpdate and not changeDelete. You only updated a value and not deleted the whole item. If you delete the item from your db then it will call changeDelete. And it is not shown after the new init because you table is filtering based on this attribute.

You will need to listen for NSFetchedResultsChangeUpdate and check there if the attribute wasDeleted is changed. If so update your table view to your needs, eg. delete the specific row.

I do the same thing in my app and have noticed that the -controller:didChangeObject:atIndexPath:forChangeType:newIndexPath:newIndexPath delegate first gets called with a change type of NSFetchedResultsChangeDelete followed by a second call with a change type of NSFetchedResultsChangeUpdate.

The NSFetchedResultsChangeUpdate might be expected behaviour, but what's left unexplained is why the first call with NSFetchedResultsChangeDelete is missing. Can you confirm you're handling this case correctly?

I had the exact same issue as you.

Do not use wasDeleted as your property name. You should not use variations of deleted when dealing with your CoreData objects.

I renamed my property to hidden, and used that for the predicate. Everything worked as you would expect.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!