NSDistributedNotificationCenter not working for dylib

℡╲_俬逩灬. 提交于 2019-12-11 11:52:14

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!