text: Q:
  
  How can I get iphone device type?
  
  I want to get iphone device type if it is iphone 2 or 3G or 4 in xcode 4.0.
  Is there any way to get it?
  If it is, please tell me.
  
  A:
  
  I found some new algorithm to get device type and iOS version.
  #include <sys/sysctl.h>
  #include <sys/utsname.h>
  
  - (NSString *) platformString{
  
  NSLog(@"[UIDevice currentDevice].model: %@",[UIDevice currentDevice].model);
  NSLog(@"[UIDevice currentDevice].description: %@",[UIDevice currentDevice].description);
  NSLog(@"[UIDevice currentDevice].localizedModel: %@",[UIDevice currentDevice].localizedModel);
  NSLog(@"[UIDevice currentDevice].name: %@",[UIDevice currentDevice].name);
  NSLog(@"[UIDevice currentDevice].systemVersion: %@",[UIDevice currentDevice].systemVersion);
  NSLog(@"[UIDevice currentDevice].systemName: %@",[UIDevice currentDevice].systemName);
  NSLog(@"[UIDevice currentDevice].batteryLevel: %f",[UIDevice currentDevice].batteryLevel);      
  struct utsname systemInfo;
  uname(&systemInfo);
  NSLog(@"[NSString stringWithCString:systemInfo.machine encoding:NSUTF8StringEncoding]: %@",[NSString stringWithCString:systemInfo.machine encoding:NSUTF8StringEncoding]);
  NSString *platform = [NSString stringWithCString:systemInfo.machine encoding:NSUTF8StringEncoding];
  
      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:@"iPhone3,2"])    return @"iPhone 4 CDMA";
  if ([platform isEqualToString:@"iPhone3,3"])    return @"Verizon iPhone 4";
  if ([platform isEqualToString:@"iPhone4,1"])    return @"iPhone 4S";
  if ([platform isEqualToString:@"iPhone5,1"])    return @"iPhone 5 (GSM)";
  if ([platform isEqualToString:@"iPhone5,2"])    return @"iPhone 5 (GSM+CDMA)";
  if ([platform isEqualToString:@"iPhone5,3"])    return @"iPhone 5c (GSM)";
  if ([platform isEqualToString:@"iPhone5,4"])    return @"iPhone 5c (GSM+CDMA)";
  if ([platform isEqualToString:@"iPhone6,1"])    return @"iPhone 5s (GSM)";
  if ([platform isEqualToString:@"iPhone6,2"])    return @"iPhone 5s (GSM+CDMA)";
  if ([platform isEqualToString:@"iPhone7,2"])    return @"iPhone 6";
  if ([platform isEqualToString:@"iPhone7,1"])    return @"iPhone 6 Plus";
  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:@"iPod5,1"])      return @"iPod Touch 5G";
  if ([platform isEqualToString:@"iPad1,1"])      return @"iPad";
  if ([platform isEqualToString:@"iPad2,1"])      return @"iPad 2 (WiFi)";
  if ([platform isEqualToString:@"iPad2,2"])      return @"iPad 2 (Cellular)";
  if ([platform isEqualToString:@"iPad2,3"])      return @"iPad 2 (Cellular)";
  if ([platform isEqualToString:@"iPad2,4"])      return @"iPad 2 (WiFi)";
  if ([platform isEqualToString:@"iPad2,5"])      return @"iPad Mini (WiFi)";
  if ([platform isEqualToString:@"iPad2,6"])      return @"iPad Mini (Cellular)";
  if ([platform isEqualToString:@"iPad2,7"])      return @"iPad Mini (Cellular)";
  if ([platform isEqualToString:@"iPad3,1"])      return @"iPad 3 (WiFi)";
  if ([platform isEqualToString:@"iPad3,2"])      return @"iPad 3 (Cellular)";
  if ([platform isEqualToString:@"iPad3,3"])      return @"iPad 3 (Cellular)";
  if ([platform isEqualToString:@"iPad3,4"])      return @"iPad 4 (WiFi)";
  if ([platform isEqualToString:@"iPad3,5"])      return @"iPad 4 (Cellular)";
  if ([platform isEqualToString:@"iPad3,6"])      return @"iPad 4 (Cellular)";
  if ([platform isEqualToString:@"iPad4,1"])      return @"iPad Air (WiFi)";
  if ([platform isEqualToString:@"iPad4,2"])      return @"iPad Air (Cellular)";
  if ([platform isEqualToString:@"i386"])         return @"Simulator";
  if ([platform isEqualToString:@"x86_64"])       return @"Simulator";
  return @"Unknown";
  }
  
  A:
  
  Actually, the UIDevice class does not have a method platformString. With undocumented methods your app will get rejected by Apple.
  [[UIDevice currentDevice] model] // e.g. "iPod touch"
  
  will do the trick. 
  
  A:
  
  Caleb is right, you shouldn't check for device type, but for functionality. For example, you can check whether the device supports multitasking like so:
  UIDevice *device = [UIDevice currentDevice];
  if ([device respondsToSelector:@selector(isMultitaskingSupported)] && [device isMultitaskingSupported]) {
      // ...code to be executed if multitasking is supported.
      // respondsToSelector: is very useful
  }
  
  If you must, you can check the iOS version, but know this is not a substitute for checking whether an object respondsToSelector:.
  #define IOS4_0 40000
  
  // You'd probably want to put this in a convenient method
  NSArray *versions = [[UIDevice currentDevice].systemVersion componentsSeparatedByString:@"."];
  NSInteger major = [[versions objectAtIndex:0] intValue];
  NSInteger minor = [[versions objectAtIndex:1] intValue];
  NSInteger version = major * 10000 + minor * 100;
  
  if (version >= IOS4_0) {
      // ...code to be executed for iOS4.0+
  }
  
  As far as I know, there is no documented way to check the device model.
  
  