On 2009 Aug 29, at 13:41, Quincey Morris wrote:

AFAIK, the problem is that NSPersistentDocument overrides *some* of NSDocument's undo-related methods, but not all, and calling the un- overridden ones really messes things up -- you can end up with 2 undo managers, one in a NSDocument private instance variable that's never used, plus the real one in the MOC.

That's another reason why I want them ^both^ to be nil.

IIRC, the correct strategy is to nil just the one in the MOC and take your grubby fingers completely off the NSDocument so that NSPersistentDocument can puts its own grubby fingers on it.

Yes, I tried that, but as shown in my demo, when NSPersistentDocument sees that is MOC does not have an undo manager it sets its own, which is not nil. This is indeed documented as noted by Ben below.

I think your third solution overrides NSPersistentDocument's override of NSDocument's undoManager, which is probably a Bad Idea, although it probably works fine in this case because you don't want any undo manager at all (so you're returning what the NSPersistentDocument override would have returned.)

Actually, the third solution is the only solution (that works).


On 2009 Aug 29, at 17:29, Ben Trumbull wrote:

You need to use the NSDocument API:

/* The document's undo manager. The default implementation of - setUndoManager:, in addition to recording the undo manager, registers the document as an observer of various NSUndoManager notifications so that -updateChangeCount: is invoked as undoable changes are made to the document. The default implementation of - undoManager creates an undo manager if the document does not already have one and -hasUndoManager would return YES. */

Yes, this is this header pretty much says the same thing as the documentation in different words. I don't see in it any admonition against overriding -undoManager to return nil as I have done. Since - hasUndoManager is a "should not override" in NSPersistentDocument, it looks like this is the "least unsupported" way to do it.

- (void)setHasUndoManager:(BOOL)hasUndoManager;

Yes, I've done that, set to nil.

So far it's working. I'll hang on to this thread for a few weeks and let y'all know if anything bad happens.

Thanks!

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to