If you’re creating a macOS program and need to identify the screen resolution of a Macintosh, you can get the height and width of the screen resolution by using the following code:
First you need to create a variable to represent the main screen (NSScreen.main()). Then you need to create a second variable (let resolution = myScreen?.frame) to identify the frame of the screen.
Now you can retrieve the width and height of the screen frame using the size.height and size.width properties. The above code uses the print command to retrieve the screen height and width but you could easily just store these values in a variable for your own program to use.