Summary

In this chapter we learned about delegation, a system that lets a programmer specify objects that should automatically be sent messages when certain events happen. We used delegation to catch the NSApplication object’s applicationDidFinishLaunching: message, which is the standard technique for specifying code that should be run when an application is initialized.

Having done this, we modified our Calculator so that it could change its size using the setFrame:display:animate: method. We also learned a little bit more about NSWindow and NSView objects.

In the next chapter, we’ll revisit our ongoing discussion of events — the basic data type used by Cocoa to keep track of actions initiated by the user. We’ll then see how events are handled by the NSResponder class, the abstract superclass of NSApplication, NSView, and NSWindow, which contains much of the Mac OS X event-handling mechanism.

Get Building Cocoa Applications: A Step by Step Guide 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.