开发者

Can't make "user switch notifications work" via notificationCenter

I am trying to use NSWorkspaceSessionDidBecomeActiveNotification to detect fast user switching but it doesn't seems to fire my handler.

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification { 
     [[[NSWorks开发者_如何学编程pace sharedWorkspace] notificationCenter]
     addObserver:self
     selector:@selector(switchHandler:)
     name:NSWorkspaceSessionDidBecomeActiveNotification
     object:nil]; 
 }

- (void) switchHandler:(NSNotification*) notification { 
     NSLog(@"User switch detected");
}

I use Apple's example Apple Link. Am I missing something?

Cheers


It looks like I should have connected my app delegate object to File's Owner/Application's delegate outlet.

awakeFromNib doesn't need that, that's why it worked.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜