• 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: Seeking advice re: placement of UndoManager
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Seeking advice re: placement of UndoManager


  • Subject: Re: Seeking advice re: placement of UndoManager
  • From: Graham Cox <email@hidden>
  • Date: Mon, 03 Sep 2012 09:11:46 +1000

On 03/09/2012, at 8:10 AM, Erik Stainsby <email@hidden> wrote:

> Advice from those who know would be much appreciated.


I wouldn't say 'I know' at all, but I find that it is necessary to put the calls to the undo manager into the model.

NSUndoManager's basic functionality acts on the model, but it also supports aspects of the view because it maintains the "action string" that is displayed in the Undo menu. As such you could say that it sits in the controller layer but unless the model tells it what to undo it can't do anything, so it relies on cooperation from the model. KVO is a good way to handle that (via some adapter class) because it's generic and so the model is not required to know about the undo manager itself - but a lot of model code predates KVO and talks to the undo manager directly (and there are some aspects of KVO that can make using it for undo awkward, like handling one-to-many relationship undos).

If you're not using NSDocument, then you could make your undo manager a singleton, but bear in mind that standard Cocoa classes (e.g. NSTextView) will expect it to be returned by the window/window's delegate via -windowWillReturnUndoManager:, so you'd have to override that method to pass back your singleton.

--Graham


_______________________________________________

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: 
 >Seeking advice re: placement of UndoManager (From: Erik Stainsby <email@hidden>)

  • Prev by Date: Security-scoped bookmark feature?
  • Next by Date: Re: Security-scoped bookmark feature?
  • Previous by thread: Re: Seeking advice re: placement of UndoManager
  • Next by thread: Security-scoped bookmark feature?
  • Index(es):
    • Date
    • Thread