In my iOS application interface, I have an explicit cancel and redo button (shake-to-undo is a pretty tough action, and cancellation is done quite often in this context). I usually use KVO to monitor the NSUndoManager canUndo and canRedo keys, as well as toggle buttons on and off when notifications appear. Unfortunately, NSUndoManager does not seem KVO-compatible for these key paths - or at least m without seeing anything in terms of notifications.
So my question is: how do I get this to work? Am I just doing it wrong with KVO? (I checked twice and three, but there is always such an opportunity). Is there any other way to do this that I don't think about? (I only mean checking the -canUndo value every time the runloop spins, but I have a bad code smell).
(Note that it is entirely possible that NSUndoManager is different from iOS and Mac OS X, so I donβt think that βIt works on Macβ would be a useful answer in this case)
cocoa-touch nsundomanager
Colin barrett
source share