Replacing undo manager in NSPersistentDocument sublclass
Replacing undo manager in NSPersistentDocument sublclass
- Subject: Replacing undo manager in NSPersistentDocument sublclass
- From: Gideon King <email@hidden>
- Date: Wed, 18 Aug 2010 03:08:19 +1000
Just a quick question. I want to change my document to using the GCUndoManager so I can actually see what's going on with undo in my application. From the documentation, I would have thought that the following was sufficient in my NSPersistentDocument subclass's -init method:
GCUndoManager* um = [[GCUndoManager alloc] init];
[um enableUndoTaskCoalescing];
[um setLevelsOfUndo:100];
[[self managedObjectContext] setUndoManager:(id)um];
[um release];
But if I do that, the updateChangeCount messages aren't sent (obviously it's not listening for the notifications from the new undo manager). However if I add:
[self setUndoManager:(id)um];
then it appears to be working. Although it is working, I am rather mystified by this, seeing as the NSPersistentDocument documentation says:
----------------
"setUndoManager: Overridden to be a no-op.
...
Parameters: undoManager - This value is ignored.
Special Considerations: You should not override this method. The persistent document uses the managed object context’s undo manager."
---------------
In my mind, that's a pretty clear statement that what I am doing should not work.
Even more interesting is that if I completely remove the:
[[self managedObjectContext] setUndoManager:(id)um];
so that it just sets the undoManager on the persistent document subclass, then it still works, leading me to believe that the documentation is completely wrong, and if you call -setUndoManager: on an NSPersistentDocument subclass, it actually sets it on the managed object context, and on the NSDocument. Correct? And does that hold true for 10.5 as well as 10.6?
Is what I'm doing OK? Is this a bug in the documentation?
Thanks
Gideon
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please 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