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.
精彩评论