Re: CoreData and Threading
Re: CoreData and Threading
- Subject: Re: CoreData and Threading
- From: patrick machielse <email@hidden>
- Date: Mon, 21 Nov 2011 01:27:50 +0100
Op 19 nov. 2011, om 17:00 heeft Frederic Testuz het volgende geschreven:
>> At the moment I cannot find an acceptable way to merge changes from the main thread into the background thread context. Is there a solution for my use case?
>>
>> I could probably try to extend a solution with locking, but it will be error proneā¦
>
> If you can limit yourself to 10.7 have you look at the changes of NSManagedObjectContext. You can now have parent-child relationship between contexts. A save: on a child context will propagate to the parent context, not to the persistent store. And a fetch: on a child context is done through the context to the parent context (if I understand correctly).
>
> I did some tests with a parent context for UI inited with NSMainQueueConcurrencyType and a child context inited with NSPrivateQueueConcurrencyType. The changes in the child context are automatically reflect in the UI after a save: on the child context.
>
> Look at the release notes for Core Data for Lion.
Thanks for the pointer. I cannot use / require 10.7 at the moment, so I've not looked at the latest additions.
Parent / child contexts seem like a useful feature. Even so, I think it would not help me in my program: my 'main' context (the one that is used for editing) is the one in the persistent document. The 'child' context is held by the background and is used 'read only'. The information must flow from the main context to the background context. All examples seem to assume editing in the background and updating the main context.
patrick
--
Patrick Machielse
Hieper Software
http://www.hieper.nl
email@hidden
_______________________________________________
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