try to create a full "model id"-list of iOS devices

Discussion in 'iPhone/iPad Programming' started by /\/\, Apr 12, 2011.

  1. macrumors regular

    Joined:
    Sep 29, 2007
    Location:
    Germany
    #1
    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:

    Code:
    + (NSString *) deviceName
    {
        struct utsname systemInfo;
        uname(&systemInfo);
        
        return [NSString stringWithCString:systemInfo.machine encoding:NSUTF8StringEncoding];
    }
    
    And here is my list of iOS devices:

    Code:
         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
     
  2. Moderator

    balamw

    Staff Member

    Joined:
    Aug 16, 2005
    Location:
    New England
    #2
    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
     
  3. Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #3
    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.
     
  4. Moderator

    balamw

    Staff Member

    Joined:
    Aug 16, 2005
    Location:
    New England
    #4
    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
     
  5. thread starter macrumors regular

    Joined:
    Sep 29, 2007
    Location:
    Germany
    #5
    Currently I need this function deviceName to know if it's an iPad or an iPhone with retina display:

    Code:
    + (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.
     
  6. Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #6
    Code:
    + (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.
     
  7. thread starter macrumors regular

    Joined:
    Sep 29, 2007
    Location:
    Germany
    #7
    :eek: ok thanks

    I'm just new in the development for iOS. :eek:
     
  8. PhoneyDeveloper, Apr 12, 2011
    Last edited: Apr 12, 2011

    macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #8
    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.
     

Share This Page