You can add a custom initializer to NSNotification.Name
extension NSNotification.Name {
enum Notifications: String {
case foo, bar
}
init(_ value: Notifications) {
self = NSNotification.Name(value.rawValue)
}
}
Usage:
NotificationCenter.default.post(name: Notification.Name(.foo), object: nil)