NSFetchedResultsController notify for changes in another entity (Best practice)

安稳与你 提交于 2019-12-25 03:27:28

问题


I have two entities (MetaData and Prices) with a many-to-many relationship. The entity MetaData has an attribute dataIsInvalid to invalidate all related prices in the entity Price. I'm using a NSFetchedResultsController for MetaData and one FRC for Price.

The predicate for FRC Price is @"ANY metaData.dataIsInvalid == 0". Of course, if I change the dataIsInvalid attribute in MetaData, the controllerDidChangeContent method from FRC Price is not called, but the method in FRC MetaData. So I want to reload the FRC Price data in the controllerDidChangeContent method from FRC MetaData.

The problem is, that the FRC Price cannot see the changes in MetaData at that time. So that doesn't work.

What is the best practice for this scenario? Should I use NSNotificationCenterwith NSManagedObjectContextDidSaveNotification? This will be called after saveToPersistentStore and the FRC Price can see the changes.

Thanks for Help.

来源:https://stackoverflow.com/questions/25914904/nsfetchedresultscontroller-notify-for-changes-in-another-entity-best-practice

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