O'Reilly logo

Learning Cocoa by Apple Computer Inc

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 11. Cocoa’s Multiple-Document Architecture

Document-based applications are one of the more common types of applications developed today. They provide a framework for generating identically contained, but uniquely composed, sets of data that can be stored in files. Word processors and spreadsheet applications are two well-known examples of document-based applications. Before investigating how document-based applications are structured, let’s consider exactly what such an application does. It:

  • Creates new documents

  • Opens existing documents that are stored in files

  • Saves documents under user-designated names and locations

  • Reverts to saved documents

  • Closes documents (usually after prompting the user to save changes)

  • Prints documents and allows the page layout to be modified

  • Represents data of different types internally

  • Monitors and sets the document’s edited status and validates menu items

  • Manages document windows, including setting the window titles

  • Handles application and window delegation methods (such as when the application terminates)

Cocoa’s remarkable multiple-document architecture consists of a set of three classes—NSDocument, NSDocumentController, and NSWindowController—which provide the features in the preceding list almost entirely “for free.” Using the multiple-document architecture drastically simplifies the work developers must do to implement a multidocument application. Once you understand how the architecture works, you can have a multidocument application up and ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required