Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>How about this code, if new version was released, you will identifier with the last know device</p> <pre><code>#include &lt;sys/types.h&gt; #include &lt;sys/sysctl.h&gt; - (NSString *)getModel { size_t size; sysctlbyname("hw.machine", NULL, &amp;size, NULL, 0); char *model = malloc(size); sysctlbyname("hw.machine", model, &amp;size, NULL, 0); NSString *sDeviceModel = [NSString stringWithCString:model encoding:NSUTF8StringEncoding]; free(model); if ([sDeviceModel isEqual:@"i386"]) return @"Simulator"; //iPhone Simulator if ([sDeviceModel isEqual:@"iPhone1,1"]) return @"iPhone1G"; //iPhone 1G if ([sDeviceModel isEqual:@"iPhone1,2"]) return @"iPhone3G"; //iPhone 3G if ([sDeviceModel isEqual:@"iPhone2,1"]) return @"iPhone3GS"; //iPhone 3GS if ([sDeviceModel isEqual:@"iPhone3,1"]) return @"iPhone4 AT&amp;T"; //iPhone 4 - AT&amp;T if ([sDeviceModel isEqual:@"iPhone3,2"]) return @"iPhone4 Other"; //iPhone 4 - Other carrier if ([sDeviceModel isEqual:@"iPhone3,3"]) return @"iPhone4"; //iPhone 4 - Other carrier if ([sDeviceModel isEqual:@"iPhone4,1"]) return @"iPhone4S"; //iPhone 4S if ([sDeviceModel isEqual:@"iPhone5,1"]) return @"iPhone5"; //iPhone 5 (GSM) if ([sDeviceModel isEqual:@"iPod1,1"]) return @"iPod1stGen"; //iPod Touch 1G if ([sDeviceModel isEqual:@"iPod2,1"]) return @"iPod2ndGen"; //iPod Touch 2G if ([sDeviceModel isEqual:@"iPod3,1"]) return @"iPod3rdGen"; //iPod Touch 3G if ([sDeviceModel isEqual:@"iPod4,1"]) return @"iPod4thGen"; //iPod Touch 4G if ([sDeviceModel isEqual:@"iPad1,1"]) return @"iPadWiFi"; //iPad Wifi if ([sDeviceModel isEqual:@"iPad1,2"]) return @"iPad3G"; //iPad 3G if ([sDeviceModel isEqual:@"iPad2,1"]) return @"iPad2"; //iPad 2 (WiFi) if ([sDeviceModel isEqual:@"iPad2,2"]) return @"iPad2"; //iPad 2 (GSM) if ([sDeviceModel isEqual:@"iPad2,3"]) return @"iPad2"; //iPad 2 (CDMA) NSString *aux = [[sDeviceModel componentsSeparatedByString:@","] objectAtIndex:0]; //If a newer version exist if ([aux rangeOfString:@"iPhone"].location!=NSNotFound) { int version = [[aux stringByReplacingOccurrencesOfString:@"iPhone" withString:@""] intValue]; if (version == 3) return @"iPhone4" if (version &gt;= 4) return @"iPhone4s"; } if ([aux rangeOfString:@"iPod"].location!=NSNotFound) { int version = [[aux stringByReplacingOccurrencesOfString:@"iPod" withString:@""] intValue]; if (version &gt;=4) return @"iPod4thGen"; } if ([aux rangeOfString:@"iPad"].location!=NSNotFound) { int version = [[aux stringByReplacingOccurrencesOfString:@"iPad" withString:@""] intValue]; if (version ==1) return @"iPad3G"; if (version &gt;=2) return @"iPad2"; } //If none was found, send the original string return sDeviceModel; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload