Re: CoreData, NSDocument and NSApplication
Re: CoreData, NSDocument and NSApplication
- Subject: Re: CoreData, NSDocument and NSApplication
- From: Marc Respass <email@hidden>
- Date: Wed, 11 Oct 2006 12:57:22 -0400
Andrew,
I've thought about this too but I haven't tried it. I think it has to
do with having all the editing context's use the same
NSPersistentStoreCoordinator.
If you look at a non-Document based CoreData app, the application
delegate sets up CoreData but in a Document-based app, the setup is
built-in to the NSPersistantDocument (which your MyDocument
subclasses). I was thinking that you can override -
managedObjectContext to return the Application's global
NSManagedObjectContext which uses the global
NSPersistentStoreCoordinator. Possibly, you would use a different
object context but the same store.
Just a thought. I haven't tried it but it seems like it would work. I
don't know if there are issues related to having multiple object
contexts for the same store. I'm also not sure about using the same
object context for multiple documents - I think that has potential
for more problems. It seems like you'd want your own object context.
Hope this helps
Marc
On Oct 11, 2006, at 8:46 AM, Andrew Bush wrote:
Hi all,
ok, so Im rather new to the CoreData stuff and Im trying to
retrofit it onto an existing application.
The existing application is a multiple document application that
opens and displays various types of files using the very boring,
very cool framework that is provided by cocoa.
Ive created a datastore file, and added some entities and some
attributes.
Ive added a NSArrayController to the document nib and bound it to
the file owner.
If I change the super of my document subclass to
NSPersistentDocument then everything appears to work honkydory.
the problem is that what I _want_ is to have a single datastore
that every document accesses, and not a separate one for every
document.
so how can I set things up so that every document is accessing the
same central datastore? I tried binding the NSArrayController to
the sharedApplication, but that just throws an error.
whats the best way to do this?
Yours cheerfully,
Andrew Bush
_______________________________________________
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
_______________________________________________
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