码迷,mamicode.com
首页 > 移动开发 > 详细

IOS获取手机设备型号

时间:2015-09-04 22:32:44      阅读:278      评论:0      收藏:0      [点我收藏+]

标签:

最新型号的设备列表https://www.theiphonewiki.com/wiki/Models

 1 #import "iosutils/IOSUtils.h"
 2 #import "sys/sysctl.h"
 3 #import "sys/utsname.h"
 4 
 5 @implementation IOSUtils
 6 
 7 + (NSString *)getCurrentDeviceModel
 8 {
 9     struct utsname systemInfo;
10     uname(&systemInfo);
11     NSString *platform = [NSString stringWithCString:systemInfo.machine encoding:NSUTF8StringEncoding];
12     
13     if ([platform isEqualToString:@"iPhone1,1"]) return @"iPhone 2G";
14     if ([platform isEqualToString:@"iPhone1,2"]) return @"iPhone 3G";
15     if ([platform isEqualToString:@"iPhone2,1"]) return @"iPhone 3GS";
16     if ([platform isEqualToString:@"iPhone3,1"]) return @"iPhone 4";
17     if ([platform isEqualToString:@"iPhone3,2"]) return @"iPhone 4";
18     if ([platform isEqualToString:@"iPhone3,3"]) return @"iPhone 4";
19     if ([platform isEqualToString:@"iPhone4,1"]) return @"iPhone 4S";
20     if ([platform isEqualToString:@"iPhone5,1"]) return @"iPhone 5";
21     if ([platform isEqualToString:@"iPhone5,2"]) return @"iPhone 5";
22     if ([platform isEqualToString:@"iPhone5,3"]) return @"iPhone 5c";
23     if ([platform isEqualToString:@"iPhone5,4"]) return @"iPhone 5c";
24     if ([platform isEqualToString:@"iPhone6,1"]) return @"iPhone 5s";
25     if ([platform isEqualToString:@"iPhone6,2"]) return @"iPhone 5s";
26     if ([platform isEqualToString:@"iPhone7,1"]) return @"iPhone 6Plus";
27     if ([platform isEqualToString:@"iPhone7,2"]) return @"iPhone 6";
28     
29     if ([platform isEqualToString:@"iPod1,1"])   return @"iPod Touch 1G";
30     if ([platform isEqualToString:@"iPod2,1"])   return @"iPod Touch 2G";
31     if ([platform isEqualToString:@"iPod3,1"])   return @"iPod Touch 3G";
32     if ([platform isEqualToString:@"iPod4,1"])   return @"iPod Touch 4G";
33     if ([platform isEqualToString:@"iPod5,1"])   return @"iPod Touch 5G";
34     
35     if ([platform isEqualToString:@"iPad1,1"])   return @"iPad 1G";
36     
37     if ([platform isEqualToString:@"iPad2,1"])   return @"iPad 2";
38     if ([platform isEqualToString:@"iPad2,2"])   return @"iPad 2";
39     if ([platform isEqualToString:@"iPad2,3"])   return @"iPad 2";
40     if ([platform isEqualToString:@"iPad2,4"])   return @"iPad 2";
41     if ([platform isEqualToString:@"iPad2,5"])   return @"iPad Mini 1G";
42     if ([platform isEqualToString:@"iPad2,6"])   return @"iPad Mini 1G";
43     if ([platform isEqualToString:@"iPad2,7"])   return @"iPad Mini 1G";
44     
45     if ([platform isEqualToString:@"iPad3,1"])   return @"iPad 3";
46     if ([platform isEqualToString:@"iPad3,2"])   return @"iPad 3";
47     if ([platform isEqualToString:@"iPad3,3"])   return @"iPad 3";
48     if ([platform isEqualToString:@"iPad3,4"])   return @"iPad 4";
49     if ([platform isEqualToString:@"iPad3,5"])   return @"iPad 4";
50     if ([platform isEqualToString:@"iPad3,6"])   return @"iPad 4";
51     
52     if ([platform isEqualToString:@"iPad4,1"])   return @"iPad Air";
53     if ([platform isEqualToString:@"iPad4,2"])   return @"iPad Air";
54     if ([platform isEqualToString:@"iPad4,3"])   return @"iPad Air";
55     if ([platform isEqualToString:@"iPad4,4"])   return @"iPad Mini 2G";
56     if ([platform isEqualToString:@"iPad4,5"])   return @"iPad Mini 2G";
57     if ([platform isEqualToString:@"iPad4,6"])   return @"iPad Mini 2G";
58     
59     if ([platform isEqualToString:@"i386"])      return @"iPhone Simulator";
60     if ([platform isEqualToString:@"x86_64"])    return @"iPhone Simulator";
61     return platform;
62 }
63 
64 @end

 

IOS获取手机设备型号

标签:

原文地址:http://www.cnblogs.com/AndyZhengLL/p/4782459.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!