问题
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 NSNotificationCenter
with 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