如何在macOS(Swift或Objective-C)上检测何时连接或断开了新显示器。
我尝试了类似的方法,但似乎不起作用:
NSDistributedNotificationCenter *nc = [NSDistributedNotificationCenter defaultCenter];
[nc addObserverForName:NSApplicationDidChangeScreenParametersNotification
object:[NSApplication sharedApplication]
queue:[NSOperationQueue mainQueue]
usingBlock:^(NSNotification *notification) {
NSLog(@"Notification %@", notification);
}];