Search code examples
swiftmacosscreen

Mac OS - Swift - Get screen containing the dock


I would like to get the screen containing the dock and the menubar. Is there a way to do this? I've check Apple documentation about NSScreen but couldn't find any information about that.

Thanks!


Solution

  • Actually, the answer was, as @Willeke suggested, in the documentation of NSScreen.screens (see: https://developer.apple.com/documentation/appkit/nsscreen/1388393-screens).

    The screen considered as main (with the menubar) is the one with index 0. It is not the same as NSScreen.main which is the screen with the current active window.