6

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

ingh.am
  • 25,981
  • 43
  • 130
  • 177

4 Answers4

7

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.

hotpaw2
  • 70,107
  • 14
  • 90
  • 153
6

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.

Community
  • 1
  • 1
westsider
  • 4,967
  • 5
  • 36
  • 51
  • @westsider Does the iPhone 4GS have the platform string `iPhone3,2`? – Besi Dec 05 '11 at 09:50
  • 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
1

-[UIDevice model], but I'm not sure if it returns anything more specific than "iPhone" or "iPod Touch".

Brian
  • 15,599
  • 4
  • 46
  • 63
1

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 -

Shaggy Frog
  • 27,575
  • 16
  • 91
  • 128