Skip navigation.
 
mlRe: Core-Data Multithreading question about save
FROM : Ben Trumbull
DATE : Thu May 22 23:07:59 2008

At 3:55 AM -0700 5/22/08, <email_removed> wrote:
>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...?).


You're grabbing the objectID from the inserted object before it's
saved.  You need to get the permanent ID from the object after it's
been saved, or you've used -obtainPermanentIDForObjects:error: (which
also does I/O, and should be used on a batch of objects)

The list archives also have these, which you should read:

<http://lists.apple.com/archives/cocoa-dev/2007/Mar/msg00739.html>
<<http://lists.apple.com/archives/cocoa-dev/2007/May/msg00222.html>http://lists.apple.com/archives/cocoa-dev/2007/May/msg00222.html>
<<http://lists.apple.com/archives/cocoa-dev/2008/Jan/msg01889.html>http://lists.apple.com/archives/cocoa-dev/2008/Jan/msg01889.html>
<http://lists.apple.com/archives/cocoa-dev/2008/Mar/msg02554.html>

--

-Ben

Related mailsAuthorDate
mlCore-Data Multithreading question about save Dex Morgan May 21, 22:25
mlRe: Core-Data Multithreading question about save Hamish Allan May 22, 00:18
mlRe: Core-Data Multithreading question about save Dex Morgan May 22, 00:36
mlRe: Core-Data Multithreading question about save Hamish Allan May 22, 01:00
mlRe: Core-Data Multithreading question about save Dex Morgan May 22, 12:37
mlRe: Core-Data Multithreading question about save Hamish Allan May 22, 14:25
mlCoreData Statement Still Active (CoreData Multithreading) Dex Morgan May 22, 16:50
mlre: CoreData Statement Still Active (CoreData Multithreading) Ben Trumbull May 22, 22:48
mlRe: Core-Data Multithreading question about save Ben Trumbull May 22, 23:07
mlRe: CoreData Statement Still Active (CoreData Multithreading) Hal Mueller May 23, 00:29