Home > Blogs > Cocoa Tip of the Day, 1/20/10

Cocoa Tip of the Day, 1/20/10

Broadcast events with notifications.

The NSNotification mechanism makes it very easy to send an event to any object that might want to handle it.  Favour this over delegates or action methods when more than one object might want to handle an event.  If other applications might need to react to the event then consider sending a distributed notification as well.

For more tips, and more detail about this tip, please see my new book,
Cocoa Programming Developer's Handbook,
available in print and electronic formats.

Become an InformIT Member

Take advantage of special member promotions, everyday discounts, quick access to saved content, and more! Join Today.