Happy New iPhone Day, everybody! And as the first in what’ll no doubt be a veritable tsunami of OS 3.0 SDK-related posts, Mobile Orchard is promising a series of “New in iPhone 3.0″ tutorials, and the first one is the definitely worthwhile Shake To Undo/Redo, NSUndoManager:
Undo/redo capabilities are provided by the
NSUndoManagerclass. The class, documented here, works by keeping a stack of messages that, if sent, would serially undo the last action, the penultimate action, and on back until arriving at the initial state.
Let’s use an example to illustrate how this works: our city, concerned with a perceived increase in the number of trucks plying our streets, has commissioned a census. City workers will tally truck traffic using an iPhone app. See a truck, tap a button. Oops! Mistook that Subaru Forester for a truck? Shake to undo.
We’ll start with working code that lacks undo/redo and add those capabilities…
Read and learn!Continue Reading →