2

Just a short overview on what my problem refers to. The data model is based on two NSManagedObject classes called "Customer" and "Reservation". The JSON I get from the web service looks like this:

"Reservation": {
    "Id": 1,
    "Reservation": "Just a description",
    "Note": "Just anything",
    "Customer": {
        "Id": 1,
        "Name": "Smith",
        "Firstname": "John",
        "Phonenumber": "00000"
    }
}

I use NSFetchedResultsController and its delegates to manage the table view. Receiving a new entry works properly. My fetchController code looks like this:

fetchedResultsController = [Reservation fetchAllSortedBy:@"name" ascending:YES withPredicate:nil groupBy:@"name"];
fetchedResultsController.delegate = self;

If anything changes in the Reservation object the table view get updated properly too. The problem just cames up when anything changes in the mapped "Customer" object like the Name, Firstname or the Phonenumber.

Checking the database.sql file makes me sure that the data get changed in the database and RestKit / Core Data works correctly. It seems that the only problem is depending on the not called delegates. If I change an Attribute in "Reservation" and "Customer" the delegates get fired (probably because of the changes in "Reservation") correctly and the table view becomes updated correctly for all Customer and Reservation properties.

If I close and reopen the App the table view gets loaded perfectly as it should.

John Topley
  • 113,588
  • 46
  • 195
  • 237
netsplit
  • 140
  • 1
  • 10
  • Unfortunately, it is just like that. A fetched results controller tracks only changes to the properties of one entity (`Reservation` in your case). It does not track changes to related objects. – Martin R Nov 14 '12 at 17:33
  • That is what I thought first too, but when I implement `NSManagedObjectContextObjectsDidChangeNotification` the notification contains the changed related object. Therefore Core Data seems to recognize the changes but doesn't fire the delegates. Is there another way to update the table view concerning related objects? – netsplit Nov 14 '12 at 22:03
  • Yes, the changes are recognized, but the FRC reacts to the changes only for its own entity. See this thread for a similar discussion: http://stackoverflow.com/questions/7533849/nsfetchedresultscontroller-with-relationship-not-updating – Martin R Nov 15 '12 at 06:45
  • Are you getting updates in any changes done to your top level attributes (in the server) which belong to the entity for which fetchedResultsController was created? For me, am not getting update callbacks even for the attributes of the entity for which am creating a NSFetchedResultsController. Please see this and answer if you have any clues: http://stackoverflow.com/questions/13457779/restkit-coredata-nsfetchedresultscontrollerdelegate-callbacks-not-triggered – Raj Pawan Gumdal Nov 19 '12 at 18:19
  • Just a thought here, but what if you setup a second fetchedResultsController using the Customer Entity? Wouldn't it then fire the controllerDidChangeEvent: method, and you could still reload the chart tableview data? – darkrat Apr 06 '13 at 16:49

0 Answers0