Skip to content

Instantly share code, notes, and snippets.

@cppforlife
Created August 27, 2011 05:52
Show Gist options
  • Save cppforlife/1175046 to your computer and use it in GitHub Desktop.
Save cppforlife/1175046 to your computer and use it in GitHub Desktop.
Reset NSNotificationCenter
// Useful in specs for debugging ran away NSNotifications.
// This code should not be used in production!
// NSNotificationCenter source: http://svn.opengroupware.org/SOPE/releases/4.4rc.1-rock/libFoundation/Foundation/NSNotificationCenter.m
static NSNotificationCenter *otherDefaultCenter;
@interface NSNotificationCenter (Reset)
+ (void)reset;
@end
@implementation NSNotificationCenter (Reset)
+ (void)initialize {
static BOOL initialized = NO;
if (!initialized) {
initialized = YES;
otherDefaultCenter = [self alloc];
[otherDefaultCenter init];
}
}
+ (void)reset {
[otherDefaultCenter release];
otherDefaultCenter = [self alloc];
[ourDefaultCenter init];
}
+ (NSNotificationCenter*)defaultCenter {
return otherDefaultCenter;
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment