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/3GS/4G etc
4 Answers
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.

- 70,107
- 14
- 90
- 153
-
I tried this, `'sysctlbyname' was not declared in this scope`. How do I declare it? – ingh.am Oct 21 '10 at 20:51
-
1Add: #include
to the relevent .h file. – hotpaw2 Oct 21 '10 at 21:00 -
Thanks. Can you find iPod/Pad the same way? – ingh.am Oct 21 '10 at 21:03
-
iPad1,1 etc. There are lists of these device names on the web. Or you can get them off of your own devices. – hotpaw2 Oct 21 '10 at 21:16
-
Yea I used the list of firmware downloads. They are named the same way! Thanks :) – ingh.am Oct 22 '10 at 08:46
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.
-
-
I can't say with certainty but web site mentioned above says that iPhone 4S (not GS) has platform string iPhone 4,1. Please see: http://www.everymac.com/systems/apple/iphone/specs/apple-iphone-4s-specs.html HTH. – westsider Dec 07 '11 at 23:28
-[UIDevice model]
, but I'm not sure if it returns anything more specific than "iPhone" or "iPod Touch".

- 15,599
- 4
- 46
- 63
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 -

- 27,575
- 16
- 91
- 128