Last active
April 26, 2017 04:27
-
-
Save jsorge/32def4d989f7ef64b1f87c2f819cf673 to your computer and use it in GitHub Desktop.
Notification.Name in Obj-C
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)createNotification { | |
NSNotification *note = [[NSNotification alloc] initWithName:JMSFoo.noteName object:nil userInfo:nil]; | |
[[NSNotificationCenter defaultCenter] postNotification: note]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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