判断iPhone 硬件设备型号
2015-11-12 17:05
543 查看
方法1:
#include <sys/sysctl.h>
- (NSString *) platform
{
size_t size;
sysctlbyname("hw.machine",NULL, &size,NULL,0);
char *machine =
malloc(size);
sysctlbyname("hw.machine", machine, &size,NULL,0);
NSString*platform = [NSStringstringWithCString:machineencoding:NSUTF8StringEncoding];
free(machine);
return platform;
}
方法2:
#import <sys/utsname.h>
NSString*machineName()
{
struct utsname systemInfo;
uname(&systemInfo);
return [NSString stringWithCString:systemInfo.machine encoding:NSUTF8StringEncoding];
}
逗号后面数字解释:(i386是指模拟器)
1-WiFi版
2-GSM/WCDMA 3G版
3-CDMA版
仅供参考:
AppleTV(2G) (AppleTV2,1)
iPad (iPad1,1)
iPad2,1 (iPad2,1)Wifi版
iPad2,2 (iPad2,2)GSM3G版
iPad2,3 (iPad2,3)CDMA3G版
iPhone (iPhone1,1)
iPhone3G (iPhone1,2)
iPhone3GS (iPhone2,1)
iPhone4 (iPhone3,1)
iPhone4(vz) (iPhone3,3)iPhone4 CDMA版
iPhone4S (iPhone4,1)
iPodTouch(1G) (iPod1,1)
iPodTouch(2G) (iPod2,1)
iPodTouch(3G) (iPod3,1)
iPodTouch(4G) (iPod4,1)
仅供参考:
@"i386" on the simulator
@"iPod1,1" on iPod Touch
@"iPod2,1" on iPod Touch Second Generation
@"iPod3,1" on iPod Touch Third Generation
@"iPod4,1" on iPod Touch Fourth Generation
@"iPhone1,1" on iPhone
@"iPhone1,2" on iPhone 3G
@"iPhone2,1" on iPhone 3GS
@"iPad1,1" on iPad
@"iPad2,1" on iPad 2
@"iPad3,1" on 3rd Generation iPad
@"iPhone3,1" on iPhone 4
@"iPhone4,1" on iPhone 4S
@"iPhone5,1" on iPhone 5 (model A1428, AT&T/Canada)
@"iPhone5,2" on iPhone 5 (model A1429, everything else)
@"iPad3,4" on 4th Generation iPad@"iPad2,5" on iPad Mini
@"iPhone5,3" on iPhone 5c (model A1456, A1532 | GSM)
@"iPhone5,4" on iPhone 5c (model A1507, A1516, A1526 (China), A1529 | Global)
@"iPhone6,1" on iPhone 5s (model A1433, A1533 | GSM)
@"iPhone6,2" on iPhone 5s (model A1457, A1518, A1528 (China), A1530 | Global)
@"iPad4,1" on 5th Generation iPad (iPad Air) - Wifi
@"iPad4,2" on 5th Generation iPad (iPad Air) - Cellular
@"iPad4,4" on 2nd Generation iPad Mini - Wifi
@"iPad4,5" on 2nd Generation iPad Mini - Cellular
PS:
附上IOS不同设备的参数URL
http://theiphonewiki.com/wiki/IPhone
http://theiphonewiki.com/wiki/IPod_touch
http://theiphonewiki.com/wiki/IPad
#include <sys/sysctl.h>
- (NSString *) platform
{
size_t size;
sysctlbyname("hw.machine",NULL, &size,NULL,0);
char *machine =
malloc(size);
sysctlbyname("hw.machine", machine, &size,NULL,0);
NSString*platform = [NSStringstringWithCString:machineencoding:NSUTF8StringEncoding];
free(machine);
return platform;
}
方法2:
#import <sys/utsname.h>
NSString*machineName()
{
struct utsname systemInfo;
uname(&systemInfo);
return [NSString stringWithCString:systemInfo.machine encoding:NSUTF8StringEncoding];
}
逗号后面数字解释:(i386是指模拟器)
1-WiFi版
2-GSM/WCDMA 3G版
3-CDMA版
仅供参考:
AppleTV(2G) (AppleTV2,1)
iPad (iPad1,1)
iPad2,1 (iPad2,1)Wifi版
iPad2,2 (iPad2,2)GSM3G版
iPad2,3 (iPad2,3)CDMA3G版
iPhone (iPhone1,1)
iPhone3G (iPhone1,2)
iPhone3GS (iPhone2,1)
iPhone4 (iPhone3,1)
iPhone4(vz) (iPhone3,3)iPhone4 CDMA版
iPhone4S (iPhone4,1)
iPodTouch(1G) (iPod1,1)
iPodTouch(2G) (iPod2,1)
iPodTouch(3G) (iPod3,1)
iPodTouch(4G) (iPod4,1)
仅供参考:
@"i386" on the simulator
@"iPod1,1" on iPod Touch
@"iPod2,1" on iPod Touch Second Generation
@"iPod3,1" on iPod Touch Third Generation
@"iPod4,1" on iPod Touch Fourth Generation
@"iPhone1,1" on iPhone
@"iPhone1,2" on iPhone 3G
@"iPhone2,1" on iPhone 3GS
@"iPad1,1" on iPad
@"iPad2,1" on iPad 2
@"iPad3,1" on 3rd Generation iPad
@"iPhone3,1" on iPhone 4
@"iPhone4,1" on iPhone 4S
@"iPhone5,1" on iPhone 5 (model A1428, AT&T/Canada)
@"iPhone5,2" on iPhone 5 (model A1429, everything else)
@"iPad3,4" on 4th Generation iPad@"iPad2,5" on iPad Mini
@"iPhone5,3" on iPhone 5c (model A1456, A1532 | GSM)
@"iPhone5,4" on iPhone 5c (model A1507, A1516, A1526 (China), A1529 | Global)
@"iPhone6,1" on iPhone 5s (model A1433, A1533 | GSM)
@"iPhone6,2" on iPhone 5s (model A1457, A1518, A1528 (China), A1530 | Global)
@"iPad4,1" on 5th Generation iPad (iPad Air) - Wifi
@"iPad4,2" on 5th Generation iPad (iPad Air) - Cellular
@"iPad4,4" on 2nd Generation iPad Mini - Wifi
@"iPad4,5" on 2nd Generation iPad Mini - Cellular
PS:
附上IOS不同设备的参数URL
http://theiphonewiki.com/wiki/IPhone
http://theiphonewiki.com/wiki/IPod_touch
http://theiphonewiki.com/wiki/IPad
相关文章推荐
- react native Text 上无法指定borderWidth 等一系列属性
- 杭电-1513Palindrome(LCS+滚动数组)
- Haskell的WriterMonad解构
- 单例类
- oc命名规范
- 没有继承性的属性
- 缩写
- web.xml加载顺序
- 实验二 作业调度模拟实验
- MIPS交叉环境的建立
- javascript(EcmaScript 5)的严格模式
- 关闭activity相关的
- 安卓开发新技能Get丨常用必备小工具汇总
- rk3288_lubuntu 定制问题
- iOS面试2
- 自定义view之圆形头像(2种实现方式)
- IOS如何选择图片加载方式:imageNamed和imageWithContentsOfFile的区别
- Ubuntu14.04安装chrome
- 我觉得比较好的资源站
- 通过RS232发送和接收短信(三)