Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
CHAPTER 10 Multiple Document Architecture So far, our examples have centered on applications that have a single GUI. However, in reality many of the applications we use day-in and day-out--such as word processors and web browsers--are based around the idea of a document. They provide a frame- work for viewing or generating identically-contained, but uniquely-composed, sets of data that can be stored in files. A document-based application must perform the following tasks: Create new documents Open existing documents stored in files Save documents to user-designated files and locations Revert to previously saved documents Close documents, usually after prompting the user to save changes Print documents and allow the page layout to be modified Monitor and set the document's edited status, as well as reflect that status to the user · Manage document windows, including setting window titles Cocoa provides a multiple-document architecture, helping you take care of these tasks easily. Using this architecture drastically simplifies the work developers must do to implement a multidocument application. Once you understand how this architecture works, you can have a multidocument application up and running in minutes. This chapter begins with an overview of Cocoa's multiple-document architecture and then presents an in-depth look at the classes that make up this architecture. The final part of the chapter guides you through the process of creating a simple multiple-docu- ment text-editing application. · · · · · · · 231