While it\'s not good practise to find out and use this information in your application, is there a way to find what model of iPhone / iPod / iPad you have. For example: 2G/3
-[UIDevice model]
, but I'm not sure if it returns anything more specific than "iPhone" or "iPod Touch".
I thought iTunes/Xcode Organizer did this already for some reason (at least I seem to remember it correctly identifying my old iPod Touch as a 1st gen), that's definitely not the case for my iPhone 3GS. Nor does the iPhone Configuration Utility help.
So I fired up System Profiler to see if the device shows up on the USB list; it does. It also shows the "Product ID" (in my case, 0x1294). I typed that into Google and came up with this:
http://theiphonewiki.com/wiki/index.php?title=Normal_Mode
Device IDs
It appears that it uses different device IDs:
iPhone - 0x1290
iPod touch - 0x1291
iPhone 3G - 0x1292
iPod touch 2G - 0x1293
iPhone 3GS - 0x1294
iPod touch 3G - 0x1299
iPad - 0x129a
iPhone 4 -
iPod touch 4G - 0x129e
Apple TV 2G -
Try:
char deviceString[256];
size_t size = 255;
sysctlbyname("hw.machine", NULL, &size, NULL, 0);
if (size > 255) { size = 255; }
sysctlbyname("hw.machine", deviceString, &size, NULL, 0);
if (strcmp(deviceString,"iPhone1,1") == 0) { etc... } // 2G
1,2 is a 3G, 2,1 is a 3GS, 3,1 is an i4, etc.
I think that this is already answered here: Determine device (iPhone, iPod Touch) with iPhone SDK, though I've added a bit to it:
- (NSString *) platformString{
NSString *platform = [self platform];
if ([platform isEqualToString:@"iPhone1,1"]) return @"iPhone 1G";
if ([platform isEqualToString:@"iPhone1,2"]) return @"iPhone 3G";
if ([platform isEqualToString:@"iPhone2,1"]) return @"iPhone 3GS";
if ([platform isEqualToString:@"iPhone3,1"]) return @"iPhone 4";
if ([platform isEqualToString:@"iPod1,1"]) return @"iPod Touch 1G";
if ([platform isEqualToString:@"iPod2,1"]) return @"iPod Touch 2G";
if ([platform isEqualToString:@"iPod3,1"]) return @"iPod Touch 3G";
if ([platform isEqualToString:@"iPod4,1"]) return @"iPod Touch 4G";
if ([platform isEqualToString:@"iPad1,1"]) return @"iPad";
if ([platform isEqualToString:@"i386"]) return @"iPhone Simulator";
return platform;
}
to account for recent additions to the family. You can checkout everyipod.com, for example, specs for iPhone 4 to get platform strings.