Good catch. When I switched the book from iOS 4 to iOS 5, I moved the Undo code from the Core Data chapter to Chapter 6 (since UIDocument also supports an undo manager). However, when I copy/pasted the text over, I clearly missed a few things.... Sorry about that.
As for the applicationDidRecieveMemoryWarning
implementation. It's probably best to put this in the TabBarController
class, since the TabBarController
creates and holds onto our WeightHistory. The implementation should look something like this:
- (void)didReceiveMemoryWarning
{
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
[self.weightHistory.undoManager removeAllActions];
}
The release calls should be deleted on page 360 and 361.
In undo on Page 360...
if ([self.managedObjectContext.undoManager canUndo])
…should be…
if ([self.undoManager canUndo])
On page 362 the book directs to implement applicationDidReceiveMemoryWarning:, but it does not state where to put it. Presumably we put this in the app delegate. However, this method is not implemented in either the chapter 6 or final versions of the downloaded source code.