Adding NotificationEnum.swift
file to your project enables declaring enum
of Notification.Name
like this:
enum MyEvent: Notification.Name {
case foo = "foo"
case bar = "bar"
}
To send notification:
NotificationCenter.default.post(name: MyEvent.foo.rawValue, ...)
To observe:
NotificationCenter.default.addObserver(..., name: MyEvent.foo.rawValue)
To switch on notification.name:
switch MyEvent(rawValue: notification.name) {
case .foo:
break
case .bar:
break
}