开发者

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

开发者 https://www.devze.com 2023-02-15 23:37 出处:网络
I am trying to use NSWorkspaceSessionDidBecomeActiveNotification to detect fast user switching but it doesn\'t seems to fire my handler.

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

精彩评论

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