PDA

View Full Version : try to create a full "model id"-list of iOS devices




/\/\
Apr 12, 2011, 06:08 AM
Hi I searched a complete "model id"-list of iOS devices in the forum, but I did not found anything.

Here is my function to get the model id of my iOS device:


+ (NSString *) deviceName
{
struct utsname systemInfo;
uname(&systemInfo);

return [NSString stringWithCString:systemInfo.machine encoding:NSUTF8StringEncoding];
}


And here is my list of iOS devices:


iPhone1,1 iPhone
iPhone1,2 iPhone 3G
iPhone2,1 iPhone 3GS
iPhone3,1 iPhone 4 (AT&T)
iPhone3,2 iPhone 4 (Verizon)
iPhone4,1 iPhone 5 (not sure)
iPhone4,2 iPhone 5 (not sure)

iPad1,1 iPad
iPad2,1 iPad2 (not sure)
iPad2,2 iPad2 (not sure)
iPad2,3 iPad2 (not sure)


Please can someone confirm / complete this list? (iPod touch devices are missing)

Thanks in advance.

Marcus



balamw
Apr 12, 2011, 08:17 AM
(iPod touch devices are missing)


You can fill in from the information here: http://www.everymac.com/systems/apple/consumer_electronics/index-ipod.html

FWIW: According to them iPhone4 CDMA is iPhone 3,3.

May I ask why you care? If you maintain such a table in your code it is basically guaranteed to be out of date when a new device comes along. If you need model breakdown, just use the "iDeviceX,Y" designation you can already retrieve.

B

robbieduncan
Apr 12, 2011, 08:25 AM
May I ask why you care? If you maintain such a table in your code it is basically guaranteed to be out of date when a new device comes along. If you need model breakdown, just use the "iDeviceX,Y" designation you can already retrieve.

Exactly. The APIs provide mechanisms to query the device from most of the capabilities you need (cameras, GPS etc) so lookups like this should not be needed.

balamw
Apr 12, 2011, 08:45 AM
Exactly. The APIs provide mechanisms to query the device from most of the capabilities you need (cameras, GPS etc) so lookups like this should not be needed.

This is a very OOP-y way of looking at it which is worth understanding.

I'm running on some device? Does that device have the property of a front facing camera? If so do something, if not do something else.

If it's strictly to get a breakdown just store the raw string you can already get.

B

/\/\
Apr 12, 2011, 05:16 PM
Currently I need this function deviceName to know if it's an iPad or an iPhone with retina display:


+ (BOOL) isIPAD
{
NSString *device = [self deviceName];

if ([device rangeOfString:@"iPad"].location != NSNotFound)
{
NSLog(@"is iPad = YES");

return YES;
}
else
{
NSLog(@"is iPad = NO");

return NO;
}
}

+ (BOOL) isIPHONE_WITH_RETINA_DISPLAY
{
NSString *device = [self deviceName];

if ([device rangeOfString:@"iPhone3"].location != NSNotFound)
{
NSLog(@"RETINA DISPLAY = YES");

return YES;
}
else if ([device rangeOfString:@"iPhone4"].location != NSNotFound)
{
NSLog(@"RETINA DISPLAY = YES");

return YES;
}
else
{
NSLog(@"RETINA DISPLAY = NO");

return NO;
}
}


I found other functions for getting this information about the retina display. They used scale or something, but I think my functions are very straightforward.

Yes you are right, this is maybe a little bit outdated when a new device will be available, but I think everybody should update the own code for the new device.

robbieduncan
Apr 12, 2011, 05:20 PM
+ (BOOL) isIPAD
{
return UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad;
}


I'm pretty sure there is a similar, Apple provided, correct way to find out if the display is "retinal" or not. The way you're doing it is brittle and, frankly, a poor design and programming decision.

/\/\
Apr 12, 2011, 05:30 PM
:o ok thanks

I'm just new in the development for iOS. :o

PhoneyDeveloper
Apr 12, 2011, 05:57 PM
What happens when they release the iPod Touch 39 or iPad 14 or the iSuperSecretNewDevice 1 or iPhone 5 with retina display? What about a device that Apple hasn't yet released to the public? Check the scale property. That's the way to do it.

There are occasionally features or behaviors or bug fixes that don't have a good way to check for their presence. But these two aren't that. There are standard suggested ways to check for iPad and Retina display so just use them.