Working with NSApplication

The NSApplication class is the primary interface between Cocoa applications and the operating system. Each Cocoa application has exactly one instance of the NSApplication class. NSApplication is seldom subclassed. It provides delegate methods and notifications that enable customization of application behavior without the need to subclass.

To show how NSApplication’s delegate methods are used, the MYDocumentManager class is created. An instance of MYDocumentManager is the application’s delegate in the new Image Viewer application and manages open documents. MYDocumentManager also allows review and saving of unsaved documents when the application quits.

NSApplication’s Delegate

The MYDocumentManager class needs to know ...

Get Cocoa® Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.