0

I have two instances of the same ViewController class accessed in different tab items. Both use the same entity, but with a different predicate. One displays all the items, while the other displays a subset based on its predicate.

The problem occurs when I delete an object from the "All" list. It updates immediately, but when I switch over to the other tab, the object is still there, even after going back and forth in the views. Only after a period of time, around 5 to 10 seconds, does the deletion get reflected in the other view.

The ViewController class use a FetchedResultsController.

Any ideas what the cause is and how to get the results to immediate appear?

Jack L.
  • 1
  • 2
  • Another consideration: I'm successful when I use the built-in application master-detail template, but when I try to use a UIManagedDocument, I can't get it to sync right away. Maybe this is a problem with the ManagedDocument only? – Jack L. Apr 02 '12 at 04:21

2 Answers2

0

Just put a reloadData into viewWillAppear. You can also catch this when the tab bar's selected index changes.

Mundi
  • 79,884
  • 17
  • 117
  • 140
  • Thanks for the reply, but I've tried that already. My guess is that it has something to do with the NSManagedObjectContext, because it only happens when I recreate the FetchedResultsController. – Jack L. Apr 02 '12 at 03:21
0

Apparently, there is no solution. There is no way to update UIManagedDocument manually.

This guy came to the same conclusion:

Core Data managed object does not see related objects until restart Simulator

So the solution is to use the default master-detail template and to stop using UIManagedDocument. Wish there was some documentation on this, would have saved me a day of my life.

Community
  • 1
  • 1
Jack L.
  • 1
  • 2