Last active
December 12, 2015 07:48
-
-
Save enigmaticape/4739327 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#import <Foundation/Foundation.h> | |
@interface Appcast : NSObject | |
+ ( id ) instance; | |
+ (void) post:(NSString *) message; | |
@end |
This file contains hidden or 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
#import "Appcast.h" | |
#import <dispatch/dispatch.h> | |
@implementation Appcast | |
+ (id) instance { | |
static id instance = nil; | |
static dispatch_once_t onceToken; | |
dispatch_once(&onceToken, ^{ | |
instance = [[self alloc]init]; | |
}); | |
return instance; | |
} | |
+ (void) post:(NSString *) message { | |
[[NSNotificationCenter defaultCenter] postNotificationName:message | |
object:[self instance]]; | |
} | |
@end |
This file contains hidden or 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
// Observe | |
[[NSNotificationCenter defaultCenter] | |
addObserver :self | |
selector :@selector(didGetNotification:) | |
name :nil | |
object :[Appcast instance] | |
]; | |
// Post | |
[Appcast post:event.pre_message]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment