Skip to content

Instantly share code, notes, and snippets.

@wagnercasey
Last active December 27, 2016 15:13
Show Gist options
  • Select an option

  • Save wagnercasey/78ce3d729d035e3e7b851e6fe6f70910 to your computer and use it in GitHub Desktop.

Select an option

Save wagnercasey/78ce3d729d035e3e7b851e6fe6f70910 to your computer and use it in GitHub Desktop.
Notification Center Sugar
enum NotificationCenterKey : String {
case screaming, yelling, hollering
}
extension NotificationCenter {
static func post(notification : NotificationCenterKey){
NotificationCenter.default.post(name: Notification.Name(rawValue: notification.rawValue), object: nil)
}
static func setObserver(observer : Any, selector : Selector, notification : NotificationCenterKey){
NotificationCenter.default.addObserver(observer, selector: selector, name: Notification.Name(rawValue: notification.rawValue), object: nil)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment