Reputation: 1871
I have a Core data managedObjectContext on the main thread, then I created another managedObjectContext on the background thread. If there is a change on the background thread I just call the ManagedObjectDidSave notification. My question is if I made a change on the mainthread, I also need to tell the managedObjectContext on the background thread right?
I have user a user data class which gets and sets userdata on both main and background thread. I should pass the managedobject of the thread I am calling this userdata class from, right?
Thanks for your help.
Upvotes: 0
Views: 887
Reputation: 64428
My question is if I made a change on the mainthread, I also need to tell the managedObjectContext on the background thread right?
If you want to make the background thread aware of any changes on the main thread you must register it for notifications. Usually, however, the background thread has some special task to process and just ignores the main thread until it is done.
I have a user data class which gets and sets userdata on both the main and background threads. I should pass the managedobject of the thread I am calling this userdata class from, right?
Yes, keep the managedObject on the same thread until the context have merged.
Upvotes: 3