0

I have an app that uses Core Data in background. Every time when i push some view controller, starts background thread which loading data from server and fills it to core data. Every view controller uses NSFetchedResultsController for realtime table update.

The problem is that when i push some view controller and from them i again push other view controller (while data loading in background) i have crash when nsfetchedresultscontroller from previous viewcontroller trying update table.

How can i fix this?

MPelletier
  • 16,256
  • 15
  • 86
  • 137
ruffnecktsk
  • 211
  • 1
  • 2
  • 4

1 Answers1

0

Are you using the same ManagedObjectContext across threads? That's very much unsupported.

Here's a good run-through on using Core Data with multiple threads. Basically, one MOC per thread, using the same StoreCoordinator, staying in sync with each others changes via notifications.

paulbailey
  • 5,328
  • 22
  • 35