I would like to know the physical screen size under Mac OSX. But NSDeviceResolution is always reporting wrong value (72), so the calculation result of resolution / dpi is wrong.
Inside “About This Mac”, there is a Mac model string there, mine is “15-inch, Early 2011”. So I’m wondering should there be a way (in obj-c probably), to read that string and then I can use that as the physical screen size.
Any help is appreciated.
You can use
CGDisplayScreenSizeto get the physical size of a screen in millimetres. From that you can compute the DPI given that you already know the resolution.So e.g.
That
@"NSScreenNumber"thing looks dodgy but is the explicit documented means of obtaining aCGDirectDisplayIDfrom anNSScreen.