Last active
April 13, 2024 12:50
-
-
Save dagronf/fca14535894070cfabb052d9969d00ea to your computer and use it in GitHub Desktop.
Observe all notifications sent through a NotificationCenter or DistributedNotificationCenter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Observe all notifications generated by the default NotificationCenter | |
NotificationCenter.default.addObserver( | |
forName: nil, object: nil, queue: nil) { notification in | |
Swift.print("Notification: \(notification.name.rawValue), Object: \(notification.object)") | |
} | |
// Observe all notifications generated by the default DistributedNotificationCenter | |
DistributedNotificationCenter.default().addObserver( | |
forName: nil, object: nil, queue: nil) { notification in | |
Swift.print("Notification: \(notification.name.rawValue), Object: \(notification.object)") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Output looks like