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

Implement a Document-Based Application

It is possible to put together a document-based application without having to write very much code. If your requirements are minimal, the Application Kit provides you with a default NSWindowController instance and a default NSDocumentController instance. You just have to create a multidocument project, compose the human interface, implement a subclass of NSDocument, and add any other custom classes or behavior required by your application.

The following procedures step you through the creation of a very simple rich text (RTF) editor. In a few minutes, and with only a few lines of code, you’ll have an application that—without Cocoa’s help—would have taken days or weeks to construct and debug.

The Document-Based Application Package

Project Builder provides a Document-Based Application project template to expedite the development of these kinds of applications. This project type provides the following things:

  • The application’s main nib file. This nib file contains a standard Cocoa application menu bar. The menu items in the File and Edit menus are already connected to appropriate first responder action methods.

  • A nib file for the application’s document. This nib file contains a single window to which other UI items can be added. A subclass of NSDocument named MyDocument has been made File’s Owner of the nib file. It (and therefore the MyDocument subclass) has an outlet to its window.

  • A skeletal NSDocument subclass implementation. The project ...

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