store management for Document Based Core Data application
store management for Document Based Core Data application
- Subject: store management for Document Based Core Data application
- From: "jorge castellanos" <email@hidden>
- Date: Tue, 12 Dec 2006 12:35:46 -0600
What would be the best approach for the following scenario?
A Document Based Core Data application has two entities:
entity-A is a library of Items that does not belong to the document, but
to the application. In other words, users can add items to the library, and
each time the application is open, the library is loaded.
entity-B is part of the document, and should be saved to the document.
Entity-B has a to-one relationship with Entity-A, and Entity A a To-many
relationship with Entity-B (In other words I need entity-B to belong to one
of the libary items).
The first aporoach I tried was to create an AppController that had its own
ManagedObjectContext and NSPersistentStoreCoordinator. Entity-A objects
would get saved to this store and thus loaded with the app and not the
documents. The Document's managed context and store would be handled by the
default NSPersistentDocument.
This kind of worked except that if I don't save the document, then the app
complains when quiting because the relationship of Entity-A to Entity-B
items is lost (when the document is closed, all Entity-B items are
destroyed, but Entity-A still has a reference to them.
So, the question is, what's the best way to deal with this?
Should I just get rid of the relationship from Entity-A to Entity-B?
Would it make sense to have only one context but the store coordinator have
multiple stores?
Any ideas or comments are appreciated.
Thanks,
J.C.
_________________________________________________________________
Don't just search. Find. Check out the new MSN Search!
http://search.msn.com/
_______________________________________________
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