On Jul 21, 2008, at 8:52 PM, Todd Heberlein wrote:

Is there a way to link a controller (e.g., the NSArrayController) to my NSDocument's NSUndoManager without having to add a bunch of code to my NSDocument subclass?

For example, in Hillegass's book, the first example of RaiseMan (Chap 8) has a nice clean design that lets the NSArrayController manage all interactions between the table view and the NSArray model.

I haven't done this example, so pardon me if I'm guessing incorrectly when it comes to what the example does…



But when adding the undo/redo capability (Chap 9) you have to add a lot of code to MyDocument to intercept and register with the NSUndoManager all insertion/deletion and edits to the model. This seems inelegant.

It would be nice to register MyDocument's NSUndoManager with the NSArrayController so that the NSArrayController can handle all the undo and redos.

That'd be neat, if you only ever edit model objects via the arrayController. Actually, even then, I don't think that'd be that neat. The document owns the model objects and, probably, the editing scope. It's plenty elegant to leave the undo manager handling logic to reside in the document instead of adding it to the arrayControllers. Oh and the treeControllers. Maybe the objectControllers? And don't forget the myAwesomeHomeGrownController.

So while what you're asking for may be possible, it wouldn't be more elegant (from my point of view) and would probably eat up just as many lines of code.



Is it possible to do this?

Thanks,

Todd



_______________________________________________

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/luesang%40apple.com

This email sent to [EMAIL PROTECTED]


--------------------------
RONZILLA



_______________________________________________

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 [EMAIL PROTECTED]

Reply via email to