Re: Core Data threading fun
Re: Core Data threading fun
- Subject: Re: Core Data threading fun
- From: Luke Evans <email@hidden>
- Date: Mon, 21 Sep 2009 11:43:03 -0700
Hi Kyle,
Actually that's exactly what the doctor ordered (I think).
I had missed this facet of using Core Data in across multiple threads.
So, thank you very much. I'm sure you have saved me a lot of time.
One last question comes to mind:
As the NSManagedObjectContextDidSaveNotification will be posted on the
main thread, is it safe to do a -
mergeChangesFromContextDidSaveNotification: on the main thread for any
given MOC?
My guess is no - unless the MOC has internal synchronisation for all
its work that this method also makes use of, then there's nothing to
stop the owning thread from updating the MOC while it's being updated
in this way.
The obvious way to deal with that would be to perform the
"mergeChanges" on the owning thread, but that will require an
appropriate runloop on each thread.
-- Luke
On 2009-09-21, at 1:31 AM, Kyle Sluder wrote:
Have you remembered to merge changes whenever a thread's MOC posts
NSManagedObjectContextDidSaveNotification? If the objects which are
seeing the stale properties haven't been faulted out or hit their
staleness interval, you will see this behavior.
Take a look at the NSManagedObject methods
-mergeChangesFromContextDidSaveNotification: and
-refreshObject:mergeChanges: for more info.
--Kyle Sluder
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden