CoreData based document NSUndoManager troubles
CoreData based document NSUndoManager troubles
- Subject: CoreData based document NSUndoManager troubles
- From: Colin Cornaby <email@hidden>
- Date: Tue, 16 Aug 2005 22:45:03 -0700
At init time for my NSPersistentDocument I clear the undo stack after
I do setup. This works fine. The stack is cleared and the document
appears as not modified. The code I use is:
[[self managedObjectContext] processPendingChanges];
[[[self managedObjectContext] undoManager] removeAllActions];
[self updateChangeCount:NSChangeCleared];
I then use the following code within an NSManagedObject subclass when
it is modified:
[[[self managedObjectContext] undoManager] registerUndoWithTarget:self
selector:@selector(setResourceData:)
object:[self valueForKey:@"data"]];
[[[self managedObjectContext] undoManager] setActionName:@"Edit
Resource"];
However, this code doesn't enable the undo menu item. I did read that
I may need to do an updateChangeCount on the NSDocument, but this
raises a few issues. First, I thought if I was using the NSDocument's
undoManager (which is shared by the managedObjectContext) that I
wouldn't need to use updateChangeCount. Secondly, the CoreData code
shouldn't really be talking to something as higher than it as the
NSPersistentDocument. Have I done something wrong? Is there any way I
can get this working without having my schema classes talk to the
NSDocument classes?
_______________________________________________
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