April 2015
Intermediate to advanced
556 pages
17h 47m
English
A view can add inverse actions for its edits to the undo manager. NSTextView, for example, can put the undo action for each edit that the user makes to the text onto the undo manager. How does the text view know which undo manager to use? First, it asks its delegate. NSTextView delegates can implement this method:
optional func undoManagerForTextView(view: NSTextView!) -> NSUndoManager?
Next, it asks its window. NSWindow inherits a property for this purpose from NSResponder:
var undoManager: NSUndoManager? { get }
The window’s delegate can supply an undo manager for the window by implementing the following method:
optional func windowWillReturnUndoManager(window: NSWindow) -> ...
Read now
Unlock full access