Skip to content

Instantly share code, notes, and snippets.

@enigmaticape
Last active December 12, 2015 07:48
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 enigmaticape/4739327 to your computer and use it in GitHub Desktop.
Save enigmaticape/4739327 to your computer and use it in GitHub Desktop.
#import <Foundation/Foundation.h>
@interface Appcast : NSObject
+ ( id ) instance;
+ (void) post:(NSString *) message;
@end
#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
// 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