Should it be possible to have a static NSNotification observer (like the code below)? I'm having some problems, and I think it may be due to my singleton class structure.
I don't always have a class instance around to listen to the notifications, but the static properties of this class stick around for my application's lifecycle.
- (id)init {
[super init]
[[NSNotificationCenter defaultCenter] addObserver:[self class]
selector:@selector(action:aNotification:)
name:@"NSSomeNotification"
object:nil];
return self;
}
+ (void)action:(NSNotification *)aNotification {
NSLog( @"Performing action" );
}
[super init]
(I didn't post my entire function). Also, I have a check that makes sure it doesn't get called multiple times, so that's not a problem either. Do you have a link that would show how to make a "true singleton" in Objective-C? – Webfoot