Given a Cocoa application which runs on Mac OS X 10.7 and later:
What is the best way to check, at runtime, if your app is currently running on a Mac with at least one retina display attached?
If checking for this sort of thing is just really wrong-headed, I fully welcome a well-reasoned explanation of why (and I will up-vote such answers if they are good).
But I'd still like to know :).
It seems likely you could just do a check specifically for the new Mac Book Pro "Retina" hardware (the only Mac which currently has a retina display), but I'd really prefer a more general/generic/future-proof way to check than this.
Ideally, I'd like to know how to detect the retina display, not the specific Mac model which currently happens to ship with a retina display.
If you really do need to do this, take a look at -[NSScreen backingScaleFactor]
. But, this does seem wrong-headed, at least without knowing more about why you want to know.
While there is currently only one Mac with a Retina display, there may eventually be standalone displays that support Retina (and can be attached/detached at runtime) and you may be able to configure the built-in Retina display in 1x mode. Thus the answer to the question "is there a Retina display attached" can change at any time.
Rather, you may want to know if your content should be drawn with a given scale by using the -convert*ToBacking:
methods or -[NSWindow backingScaleFactor]
. For a ton more detail, watch the WWDC 2012 session video "Advanced Tips and Tricks for High Resolution on OS X" (when posted, hopefully within the next few weeks).