• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: linking NSArrayController and Undo manager
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: linking NSArrayController and Undo manager


  • Subject: Re: linking NSArrayController and Undo manager
  • From: Ron Lue-Sang <email@hidden>
  • Date: Thu, 24 Jul 2008 19:00:29 -0700


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 (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


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



_______________________________________________

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


References: 
 >linking NSArrayController and Undo manager (From: Todd Heberlein <email@hidden>)

  • Prev by Date: Re: Cleaning up my Data Model
  • Next by Date: Correct way to commit pending text field edits?
  • Previous by thread: linking NSArrayController and Undo manager
  • Next by thread: passing argument 1 of 'stringWithFormat:' makes pointer from integer without a cast
  • Index(es):
    • Date
    • Thread