How to use CoreData with multiple threads and ManagedObjectContexts
How to use CoreData with multiple threads and ManagedObjectContexts
- Subject: How to use CoreData with multiple threads and ManagedObjectContexts
- From: Matt Ronge <email@hidden>
- Date: Sun, 27 Nov 2005 00:45:12 -0600
I'm working on an application that is going to have a data store, a user
interface that reads from the data store and a worker thread that
updates the data store by making network calls via an IMAP library.
Right now, my application has an internal set of objects which bindings
are attached to. However, I'd like to move this to a CoreData store to
make persistence easier, and I'm not clear on how to work with CoreData
and multiple threads.
I read that it's suggested that each thread have it's own
NSManagedObjectContext. So if each of my threads has their own
NSManagedObjectContext, and I update one ManagedObjectContext, will the
ManagedObjectContext in the other thread be magically updated as well?
To make things more clear, if my worker thread updates it's
NSManagedObjectContext will the NSManagedObjectContext which the
bindings are attached to change as well? I'm guessing no, since that
seems too easy?
Or should I share the same NSManagedObjectContext and do a trylock on it
before either thread accesses it?
Thanks alot, and I apologize if this is in the docs someplace.
--
Matt Ronge
www.theronge.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden