Delegates
Delegates and delegate methods are used throughout the Application Kit. Delegates provide an alternative to subclassing when the behavior of classes must be refined to meet an application’s needs. Application Kit classes such as NSApplication, NSWindow, NSBrowser, and NSMatrix are seldom subclassed. Delegation enables all the customization that most applications need.
A delegate is an object that is able to influence the behavior of another object by responding to delegate messages. A class that uses a delegate has a delegate instance variable and defines a number of delegate methods. An instance of that class sends delegate messages to its delegate for help deciding how to behave. For example, the NSWindow class has a delegate and ...
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.