Re: [COREDATA] Assign NSManagedObject to persistent store
Re: [COREDATA] Assign NSManagedObject to persistent store
- Subject: Re: [COREDATA] Assign NSManagedObject to persistent store
- From: Guillaume Rager <email@hidden>
- Date: Wed, 14 Dec 2005 08:18:43 +0100
Le 13 déc. 05 à 17:37, Bill Bumgarner a écrit :
On Dec 13, 2005, at 6:50 AM, Guillaume Rager wrote:
I have one managedObjectContext and two persistent stores
(sqlstore and inMemoryStore) linked to this context.
Each time I create a managed object, it is assigned to the
sqlstore or to the inMemoryStore. But sometimes I would like to
finally put an object from inMemoryStore to sqlStore, but
"coredata" does not seem to be ok, because context has been
already saved.
So, do you have any solution to move a given object into another
store ?
Once an object is saved into a store, that instance of that managed
object will always live in that store. There is no notion of
moving an object from one store to another.
At first glance, this may seem like an oversight on the part of the
Core Data implementation. The problem is actually considerably
more difficult. Core Data is all about managing a complex object
graph; managing a set of objects that have relationships between
each other.
If you were to move one object, what does that imply for the rest
of the object graph? Without cross store relationships (which
are really hard in generic terms), it would imply that the object
and everything it is connected to would also have to move from one
store to the other.
Out of curiosity, why do you have the two stores in the first place?
Well some objects are created from a "source", but we dont usually
need to save them, so they are in inMemoryStore. But sometimes, these
objects are detached from the source (some attributes are changed),
so we need to keep in database these changes, this is why we need to
move modified objects to sqlStore.
So I guess that I have to create a "copy" of the modified object and
put into the sqlStore and remove the old one from the inMemoryStore...
b.bum
Guillaume
-----------
GUMITECH - France
http://www.gumitech.com
"Chaud cocoa, chaud chocolat !"
_______________________________________________
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