subclasses of NSPersistentDocument and NSManagedObjectContext, and undo
subclasses of NSPersistentDocument and NSManagedObjectContext, and undo
- Subject: subclasses of NSPersistentDocument and NSManagedObjectContext, and undo
- From: Don Briggs <email@hidden>
- Date: Wed, 25 May 2005 14:00:52 -0500
Hello, all —
I, too, need a subclass of NSPersistentDocument to use a subclass of
NSManagedObjectContext.
I followed mmalc's code below, and it works for me -- with just one
glitch.
The documents act, save and open as expected.
I can add and remove contained objects, and edit them.
The undo commands work fine.
But, but ... the documents just never get dirty, no matter what I do
to the contained objects.
(The contained objects are instances of subclasses of NSManagedObject.)
I rather expected that NSManagedObjectContext and
NSPersistentDocument would just "do the right thing" without further
guidance from me.
What did I neglect or botch? Any guesses?
Don
On May 22, 2005, at 9:13 PM, Todd Blanchard wrote:
I've been digging, literally for about 6 hours trying to get a
clear understanding of NSPersistentDocument's initialization process.
I have a subclass of NSManagedContext that I want my subclass of
NSPersistentDocument to use.
Where is the good place to arrange for the NSPersistentDocument to
get my subclass?
I suppose I could use posing, but I'd prefer something more
straightforward.
Per the documentation:
"You can customize the architecture of the persistence stack by
overriding the methods managedObjectModel and
configurePersistentStoreCoordinator:forURL:ofType:error:."
- (NSManagedObjectContext *)managedObjectContext
{
if (myManagedObjectContext == nil) {
myManagedObjectContext = [[MyManagedObjectContext alloc]
init];
NSPersistentStoreCoordinator *psc =
[[NSPersistentStoreCoordinator alloc]
initWithManagedObjectModel:[self managedObjectModel]];
[myManagedObjectContext setPersistentStoreCoordinator:psc];
}
return myManagedObjectContext;
}
_______________________________________________
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