I have two entities in Core Data (see below), and using NSFetchedResultsController
with [NSPredicate predicateWithFormat:@"calendar.subscribed == 1"];
to extract "Event" object.
Calendar
- subscribed (BOOL)
- events (one-to-many relationship to "Event")
Event
- calendar (many-to-one relationship to "Calendar")
Everything works fine, but if I change subscribed
property of some "Calendar" and save the context in other thread, controllerDidChangeContent
isn't been called.
can I force to refetch? and how?
Sadly the FRC only monitors the objects that are the subject of the fetch (in your case
Event
). So it does not recognise changes to attributes of related objects, even though those changes might affect how the predicate evaluates.One workaround (if you can live with the performance hit) is, when you change the
Calendar
object's attribute value, to change a value on the associatedEvent
object to its existing value - no change in theory, but enough to trigger the FRC to re-evaluate the predicate for thatEvent
.