Skip to content

Instantly share code, notes, and snippets.

@jsorge
Last active April 26, 2017 04:27
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 jsorge/32def4d989f7ef64b1f87c2f819cf673 to your computer and use it in GitHub Desktop.
Save jsorge/32def4d989f7ef64b1f87c2f819cf673 to your computer and use it in GitHub Desktop.
Notification.Name in Obj-C
- (void)createNotification {
NSNotification *note = [[NSNotification alloc] initWithName:JMSFoo.noteName object:nil userInfo:nil];
[[NSNotificationCenter defaultCenter] postNotification: note];
}
protocol NotificationSupporting {
static var noteName: String { get }
static var notification: Notification.Name { get }
}
extension NotificationSupporting {
public static var notification: Notification.Name {
return Notification.Name(rawValue: self.noteName)
}
}
@objc(JMSFoo)
class Foo: NSObject, NotificationSupporting {
public static let noteName: String = "HelloWorld"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment