Posting and Observing Notifications
Send and receive app-wide events.
NotificationCenter
NotificationCenter is a broadcast mechanism: one part of the app posts a notification and any number of observers react, without the sender and receivers knowing each other.
The Default Center
Most code uses NotificationCenter.default, a shared center that routes notifications across the process.
import Foundation
let center = NotificationCenter.default
print("Using the default notification center")All lessons in this course
- Posting and Observing Notifications
- Notification userInfo Payloads
- Removing Observers Safely
- The Observer Pattern Alternatives