Cocoa Programming for OS X: The Big Nerd Ranch Guide
by Aaron Hillegass, Adam Preble, Nate Chandler
For the More Curious: Delegates and Notifications
An object that has made itself the delegate of a standard Cocoa object is probably interested in receiving notifications from that object as well. For example, if you have implemented a delegate to handle the windowShouldClose(_:) delegate method for a window, that same object is likely to be interested in the NSWindowDidResizeNotification from that same window.
If a standard Cocoa object has a delegate and posts notifications, the delegate is automatically registered as an observer for the methods it implements. If you are implementing such a delegate, how would you know what to call the method?
The naming convention is simple: Start with the name of the notification. Remove the ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access