Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Recipe 7. Refine the Document’s Usabilit... > Step 9: Implement the Revert to Save...

Step 9: Implement the Revert to Saved Menu Item

In Step 7, you wrote code to autosave the Chef’s Diary and to retrieve its previously autosaved contents after a crash or power failure. In Step 8, you wrote code to back up the document automatically so that the user can retrieve its previous contents even after changes have been saved. One similar operation remains to be coded: the Revert to Saved menu item in the application’s File menu. This menu item allows the user to retrieve the last saved Chef’s Diary contents, discarding changes made since the last save.

Currently, the application’s Revert to Saved menu item doesn’t work correctly. It is connected by default to its built-in NSDocument action method, -revertDocumentToSaved:, but if you choose File > Revert to Saved after saving the diary document and typing some new text, the application crashes. To compound the problem, the menu item is enabled under the wrong conditions. You have to write some code to get this right.


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial