Document-Based Applications
Most
applications create, manage, and
edit documents. A document can be anything that stores persistent
data. Moreover, these applications all duplicate common
functionality, such as the ability to create new documents, open
existing documents, and manage multiple open documents. Cocoa
provides a multiple-document application architecture that implements
most of the basic functionality shared by all document-based
applications. Cocoa document-based application architecture centers
on the NSDocument,
NSDocumentController, and
NSWindowController classes.
When developing a document-based application, most development effort
is likely to be spent implementing subclasses of
NSDocument
; any document-based application must have
at least one NSDocument subclass, but may have
more (think of AppleWorks, for example). In MVC terminology, an
NSDocument is a controller object; it manages a
document’s persistent data, and to project that data
into a view. This means that minimally an
NSDocument subclass must know how to load data
into a form useable by the application, as well as how to store this
data into a persistent form. A well-implemented document subclass
also provides support for printing, undo/redo operations, and edited
status tracking.
An
NSDocumentController
instance is the administrator of a
document-based application. It is responsible for servicing user
requests to create, open, and save documents.
NSDocumentController serves the integral role of ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access