How to get objects after CoreData Context merged

Posted by Emmettoc on Stack Overflow See other posts from Stack Overflow or by Emmettoc
Published on 2010-06-05T13:48:51Z Indexed on 2010/06/05 13:52 UTC
Read the original article Hit count: 385

Filed under:
|
|

Hi,

I tried to save data and merge with CoreData and multi-thread for iPhone app. But I can't get managed objects in the main thread after merging.

I wrote code just like this:

[managedObjectContext performSelectorOnMainThread:@selector(mergeChangesFromContextDidSaveNotification:)
                                       withObject:notification
                                    waitUntilDone:YES];

[self performSelectorOnMainThread:@selector(didMerged:) withObject:objectIds waitUntilDone:YES];

So I tried to pass objectIds to get NSManagedObject instances in the main thread which were generated in another thread. At first I tried "objectWithId" method but it generated fault objects. Then I tried "existingObjectWithID" method but it generated objects partly and others were nil with following Error:

[Error] Error Domain=NSCocoaErrorDomain Code=133000 "Operation could not be completed. (Cocoa error 133000.)"

What is wrong? Is there any way how to retrieve all objects by objectIds after merging in another thread?

Thank you.

© Stack Overflow or respective owner

Related posts about iphone

Related posts about cocoa