检测何时在macOS上连接了新显示器

时间:2019-05-08 14:39:04

标签: macos cocoa

如何在macOS(Swift或Objective-C)上检测何时连接或断开了新显示器。

我尝试了类似的方法,但似乎不起作用:

NSDistributedNotificationCenter *nc = [NSDistributedNotificationCenter defaultCenter];
[nc addObserverForName:NSApplicationDidChangeScreenParametersNotification
                   object:[NSApplication sharedApplication]
                    queue:[NSOperationQueue mainQueue]
               usingBlock:^(NSNotification *notification) {
                  NSLog(@"Notification %@", notification);
               }];

0 个答案:

没有答案