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
if([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad){
    //IPAD        
    if ([[UIScreen mainScreen] isRetina]) {
        // IPAD 3 - Retina display
        bannersGetPromoServerRequest.size = kXML_API_IMAGESIZE_IPAD_HIGHRES;            
    }else{
        //iPAD 1/2
        bannersGetPromoServerRequest.size = kXML_API_IMAGESIZE_IPAD_LOWRES;        }
}else{
    //IPHONE
    if ([[UIScreen mainScreen] isRetina]) {
        // IPHONE 4/4s/5 - Retina display
        bannersGetPromoServerRequest.size = kXML_API_IMAGESIZE_IPHONE_HIGHRES;
    }else{
        //IPHONE (3.x)
        bannersGetPromoServerRequest.size = kXML_API_IMAGESIZE_IPHONE_LOWRES;
    }
}
- (NSString *) platform  
{  
    size_t size;  
    sysctlbyname("hw.machine", NULL, &size, NULL, 0);  
    char *machine = malloc(size);  
    sysctlbyname("hw.machine", machine, &size, NULL, 0);  
    NSString *platform = [NSString stringWithCString:machine];  
    free(machine);  
    return platform;  
}  
- (NSString *) platformString  
{  
    NSString *platform = [self platform];  
    if ([platform isEqualToString:@"iPhone1,1"]) return @"Original iPhone";  
    if ([platform isEqualToString:@"iPhone1,2"]) return @"iPhone 3G";  
    if ([platform isEqualToString:@"iPhone2,1"]) return @"iPhone 3G[S]"; 
    if ([platform isEqualToString:@"iPhone3,1"]) return @"iPhone 4";   
    return @"Unknown";  
}  
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
}