Re: Core-Data Multithreading question about save
Re: Core-Data Multithreading question about save
- Subject: Re: Core-Data Multithreading question about save
- From: Dex Morgan <email@hidden>
- Date: Thu, 22 May 2008 12:37:26 +0200
Il giorno 22/mag/08, alle ore 01:00, Hamish Allan ha scritto:
Do you really need to do this after every object inserted? Could you
do it in bulk?
Not necessarily.
I've tried to do this sequence:
- my second thread add objects into second context until the end
saving each objectID in an array
- after all insertions was finished I call -save: on second context
then I try to take the object from the main context using the objectID
saved. However the object seems not updated (all attributes was empty)
and I've noticed that saved objectID is temporany. I've also tried to
save both second/first managedobject before doing these actions but
the id still temporany.
What's I'm wrong? The ID still temporany until I save the second
managed object but If I can do it I can also make my relationship, the
overhead it's the same.
The doc says I can pass objects between contexts by the relative ID
(but if the ID is temp what should I need to pass...?).
Do you really need to do the inserts on a separate thread? Could you
have your worker thread call
performSelectorOnMainThread:withObject:waitUntilDone: and have the
main thread perform the inserts at the end of each run loop iteration?
I need to work in a multithreading environment.
_______________________________________________
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