Notifications

Notifications are a mechanism for broadcasting a simple message throughout an application. A notification can be posted from anywhere, and any object instance can register for a notification that a message has been posted. Notifications work similar to radio signal station broadcasting on a specific frequency, and objects registered for a notification are like radios tuned to that frequency. As the analogy suggests, coupling between notification posters and listeners is minimal.

Adding observers and posting notifications are both done through a Singleton instance of NSNotificationCenter available through the NSNotification class method defaultCenter. A poster has no idea about the listener or number of listeners if a notification ...

Get Reactive Programming with Swift 4 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.