I am trying to build a game for the iphone using cocos2d engine. I wanted to know how can I tell a difference whether the user is using iphone 4 or iphone 3 as I wanted to l
Checking the scale property is not sufficient, as on iPad 3.2 in 2x mode, the scale property exists and will return 2.0, but we know that device does NOT have a Retina display.
I've created at category on UIScreen to do this. For a more detailed explanation, see my answer to Detect Retina Display. Here's the code:
@interface UIScreen(ZBScreenRetinaAdditions)
// Returns YES if this is a Retina display.
- (BOOL)zb_isRetina;
@end
@implementation UIScreen(ZBScreenRetinaAdditions)
- (BOOL)zb_isRetina {
return [self respondsToSelector:@selector(displayLinkWithTarget:selector:)] && (self.scale == 2.0);
}
@end
Usage example:
if ([UIScreen mainScreen] zb_isRetina) {
// Retina display
}