Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 598
bTagTiger Avatar asked Oct 01 '11 12:10

bTagTiger


People also ask

How do I find the device type on my iPhone?

Go to Settings > General > About. To the right of Model, you'll see the part number. To see the model number, tap the part number.

How do I identify my device?

Check your phone's settingsGo to the Settings or Options menu, scroll to the bottom of the list, and check 'About phone', 'About device' or similar. The device name and model number should be listed.

What is device type iOS?

iOS is one of the most popular mobile operating system developed and created by Apple Inc. An iOS device is an electronic gadget that runs on iOS. Apple iOS devices include: iPad, iPod Touch and iPhone. iOS is the 2nd most popular mobile OS after Android.


1 Answers

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";
}
like image 192
Yi Jiang Avatar answered Oct 02 '22 12:10

Yi Jiang