Skip to content

Instantly share code, notes, and snippets.

@serhii-londar
Created March 27, 2018 07:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save serhii-londar/624d1efe644b09957df9b7926d99faee to your computer and use it in GitHub Desktop.
Save serhii-londar/624d1efe644b09957df9b7926d99faee to your computer and use it in GitHub Desktop.
public protocol NotificationName {
var name: Notification.Name { get }
}
public extension RawRepresentable where RawValue == String, Self: NotificationName {
public var name: Notification.Name {
get {
return Notification.Name(self.rawValue)
}
}
}
class MyClass {
enum Notifications: String, NotificationName {
case myNotification
}
}
NotificationCenter.default.post(name: Notifications.myNotification.name, object: nil)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment