Re: [CoreData] Background Insertion
Re: [CoreData] Background Insertion
- Subject: Re: [CoreData] Background Insertion
- From: Andrew Kimpton <email@hidden>
- Date: Tue, 5 Jun 2007 11:59:19 -0400
On Jun 5, 2007, at 11:27 AM, Marcus S. Zarra wrote:
Andrew,
I do updates on a background thread also. When I am done on the
background thread I then make a call to the main thread and I pass
it the objectID for each object that was touched in the background
thread. Then on the main thread, I loop through these objectIDs
and call -refreshObject:mergeChanges: on each object. This lets
the main thread know that the object has changed and handles
updates from the main thread properly.
I am not sure how viable this would be in your case but it is a
solution that does work.
This would be a fine solution for me - however my problem is that
objectRegisteredForID returns nil when called against the managed
object context in the main thread for an object ID that was just
inserted into the context of the background thread. For other
scenarios where the background thread has caused an update to the
object then the objectRegisteredForID call returns a valid pointer.
It's only the newly inserted objects for which I get nil.
In your app are you also inserting objects in the background thread ?
Or only causing updates to already existing objects ? If you are
inserting objects do you also send a save message to the background
threads context during the processing of the background thread ? Or
do you defer the save to the main thread for some later date ? Right
now I save in the background thread too - and I'm wondering if that
causes a problem (I do lock the store coordinator).
Andrew 8-)
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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