问题
I have some Objective-C code which registers for notifications like this:
@implementation MyClass
- (id)init
{
self = [super init]
[[NSDistributedNotificationCenter defaultCenter] addObserver:self
selector:@selector(onNotify:)
name:@"com.apple.screensaver.didstart"
object:nil];
}
- (void)onNotify:(NSNotification *)aNotification
{
// do something with notification
}
@end
This works absolutely fine when compiled into an app, but I do not get any notifications when compiled into a dylib which is then loaded into an app.
Any ideas?
来源:https://stackoverflow.com/questions/8505440/nsdistributednotificationcenter-not-working-for-dylib