Created
August 27, 2011 05:52
-
-
Save cppforlife/1175046 to your computer and use it in GitHub Desktop.
Reset NSNotificationCenter
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
// 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