O'Reilly logo

Cocoa in a Nutshell by James Duncan Davidson, Michael Beam

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

Application Architecture

The Application Kit’s basic architecture is primarily implemented in three classes: NSApplication , NSWindow , and NSView . Figure 3-3 shows the class hierarchy for these classes. Individually, these three classes provide the means for an application to interface with the operating system (and ultimately, the user) via connections to Quartz, the window server, and underlying Unix libraries through Core Foundation. Taken as a whole, these classes form the backbone of the Application Kit’s event-handling infrastructure.

The hierarchical relationship between NSApplication, NSWindow, and NSView; these three classes all have a common parent in NSResponder
Figure 3-3. The hierarchical relationship between NSApplication, NSWindow, and NSView; these three classes all have a common parent in NSResponder

The Application

Fundamental to every Cocoa application is a singleton instance of NSApplication (accessible by using the class method sharedApplication or the global variable, NSApp). NSApplication provides a link to the window server and other essential operating system services. One of its most important responsibilities is management of the application’s run loop and event handling. Run loops have the job of managing input from sources such as the mouse and keyboard (through the window server), ports, and timers. As the owner of the application’s main run loop, NSApplication is the first stop for event processing in an application. Through a direct connection to the window server, NSApplication accepts ...

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