IOS 获取最新设备型号方法
1.IOS 获取最新设备型号方法
列表最新对照表:http://theiphonewiki.com/wiki/Models
方法:
#import "sys/utsname.h”
struct utsname systemInfo;
uname(&systemInfo); NSString *deviceString = [NSString stringWithCString:systemInfo.machine encoding:NSUTF8StringEncoding];
这样得到的 deviceString 是iPhone5,2 的设备号,根据对照表可以获取到当前手机型号。
完整函数:
struct utsname systemInfo;
uname(&systemInfo);
NSString *deviceString = [NSString stringWithCString:systemInfo.machine encoding:NSUTF8StringEncoding]; NSArray *modelArray = @[ @"i386", @"x86_64", @"iPhone1,1",
@"iPhone1,2",
@"iPhone2,1",
@"iPhone3,1",
@"iPhone3,2",
@"iPhone3,3",
@"iPhone4,1",
@"iPhone5,1",
@"iPhone5,2",
@"iPhone5,3",
@"iPhone5,4",
@"iPhone6,1",
@"iPhone6,2", @"iPod1,1",
@"iPod2,1",
@"iPod3,1",
@"iPod4,1",
@"iPod5,1", @"iPad1,1",
@"iPad2,1",
@"iPad2,2",
@"iPad2,3",
@"iPad2,4",
@"iPad3,1",
@"iPad3,2",
@"iPad3,3",
@"iPad3,4",
@"iPad3,5",
@"iPad3,6", @"iPad2,5",
@"iPad2,6",
@"iPad2,7",
];
NSArray *modelNameArray = @[ @"iPhone Simulator", @"iPhone Simulator", @"iPhone 2G",
@"iPhone 3G",
@"iPhone 3GS",
@"iPhone 4(GSM)",
@"iPhone 4(GSM Rev A)",
@"iPhone 4(CDMA)",
@"iPhone 4S",
@"iPhone 5(GSM)",
@"iPhone 5(GSM+CDMA)",
@"iPhone 5c(GSM)",
@"iPhone 5c(Global)",
@"iphone 5s(GSM)",
@"iphone 5s(Global)", @"iPod Touch 1G",
@"iPod Touch 2G",
@"iPod Touch 3G",
@"iPod Touch 4G",
@"iPod Touch 5G", @"iPad",
@"iPad 2(WiFi)",
@"iPad 2(GSM)",
@"iPad 2(CDMA)",
@"iPad 2(WiFi + New Chip)",
@"iPad 3(WiFi)",
@"iPad 3(GSM+CDMA)",
@"iPad 3(GSM)",
@"iPad 4(WiFi)",
@"iPad 4(GSM)",
@"iPad 4(GSM+CDMA)", @"iPad mini (WiFi)",
@"iPad mini (GSM)",
@"ipad mini (GSM+CDMA)"
];
NSInteger modelIndex = - ;
NSString *modelNameString = nil;
modelIndex = [modelArray indexOfObject:deviceString];
if (modelIndex >= && modelIndex < [modelNameArray count]) {
modelNameString = [modelNameArray objectAtIndex:modelIndex];
} NSLog(@"----设备类型---%@",modelNameString);
注:struct utsname systemInfo; 这是LINUX系统放硬件版本的信息的地方。
附录:
// IOS-获取Model(设备型号)、Version(设备版本号)、app(程序版本号)等
NSLog(@"name: %@", [[UIDevice currentDevice] name]);
NSLog(@"systemName: %@", [[UIDevice currentDevice] systemName]);
NSLog(@"systemVersion: %@", [[UIDevice currentDevice] systemVersion]);
NSLog(@"model: %@", [[UIDevice currentDevice] model]);
NSLog(@"localizedModel: %@", [[UIDevice currentDevice] localizedModel]); NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary]; CFShow((__bridge CFTypeRef)(infoDictionary)); // app名称
NSString *app_Name = [infoDictionary objectForKey:@"CFBundleDisplayName"];
// app版本
NSString *app_Version = [infoDictionary objectForKey:@"CFBundleShortVersionString"];
// app build版本
NSString *app_build = [infoDictionary objectForKey:@"CFBundleVersion”];
----------备注记录之用
IOS 获取最新设备型号方法的更多相关文章
- IOS获取手机设备型号
最新型号的设备列表https://www.theiphonewiki.com/wiki/Models #import "iosutils/IOSUtils.h" #import & ...
- iOS获取用户设备崩溃日志并分析
项目最近发布,部分用户在内侧使用,正好遇到一些问题,由于用户在其他城市,所以对于用户设备产生的崩溃日志,不好直接拿设备连接电脑. 对于这种情况,我们可以这样: 1.引导用户开启iOS设备设置-> ...
- ios 获得设备型号方法
以前用UIScreen 的大小来判断设备类型,现在有了iphone6 和 iphone6 plus, 这种方法不能用了.因为当程序不提供相应的启动图片时,系统会把程序运行在320*568的size下, ...
- [方法提炼] 获取Android设备序列号方法
通过这个方法可以检测设备是否连接成功,如果有一台或者多台设备,可以将所有设备序列号全部输出 # -*- coding:utf-8 -*- import os def attachDeviceList( ...
- iOS 获取沙盒路径方法
//获取家目录路径的函数: NSString *homeDir = NSHomeDirectory(); //获取Documents目录路径的方法: NSArray *paths = NSSearch ...
- iOS 获取手机的型号,系统版本,软件名称,软件版本
转载自:http://www.2cto.com/kf/201210/162333.html 网上搜索出来的,记录下来以后使用方便: [java]//手机序列号 NSString* ide ...
- ios 获取当前设备信息、内存
//在[UIDevice currentDevice]中的属性 @property(nonatomic,readonly,strong) NSString *name; // e.g. "M ...
- ios 获取手机设备信息
[UIDevice currentDevice]:表示设备 NSString *devices=[[NSString alloc] initWithFormat: @"unique id: ...
- iOS获取当前设备方向
三种方式: self.interfaceOrientation [[UIApplication sharedApplication] statusBarOrientation] [[UIDevice ...
随机推荐
- Stanford机器学习---第一讲. Linear Regression with one variable
原文:http://blog.csdn.net/abcjennifer/article/details/7691571 本栏目(Machine learning)包括单参数的线性回归.多参数的线性回归 ...
- 南洋理工 OJ 115 城市平乱 dijstra算法
城市平乱 时间限制:1000 ms | 内存限制:65535 KB 难度:4 描述 南将军统领着N个部队,这N个部队分别驻扎在N个不同的城市. 他在用这N个部队维护着M个城市的治安,这M个城市 ...
- 【Spring】Spring系列5之Spring支持事务处理
5.Spring支持事务处理 5.1.事务准备 以上代码结构与AOP的前置通知.返回通知.异常通知.后置通知一样. 5.2.声明式事务 5.2.1.基于注解 5.2.2.基于配置文件 5. 3.事务传 ...
- First Position of Target
For a given sorted array (ascending order) and a target number, find the first index of this number ...
- poj 1833
http://poj.org/problem?id=1833 next_permutation这个函数是用来全排列的,按字典的序进行排列,当排列无后继的最大值时,会执行字典升序排列,相当于排序: 当排 ...
- HAST 使用笔记
1.环境 2台 freebsd 9.2的机器,/home分区为260G,需要将其转为hast块设备 2.安装 (1)先umount /home,然后注释掉/etc/fstab上的/home记录: # ...
- Python Elasticsearch api
描述:ElasticSearch是一个基于Lucene的搜索服务器.它提供了一个分布式多用户能力的全文搜索引擎,基于RESTful web接口.下面介绍了利用Python API接口进行数据查询,方便 ...
- 【python】继承时注意事项
1. __init__ 注意事项 如果父类有__init__函数,子类没有,则子类自动调用父类__init__函数 如果父类有__init__函数,子类也有,则子类必须主动调用父类__init__函数 ...
- HttpHandler简介
新建的一般处理程序后缀为.ashx,一般会另外新建一个后缀为.ashx.cs的文件,其实所有的代码都写在.ashx.cs里面,只是微软帮我们做了一个傻瓜化的转换新建的一般处理程序,如:Text1,它就 ...
- c++ static及const(开发者在线)
static 是c++中很常用的修饰符,它被用来控制变量的存储方式和可见性,下面我将从 static 修饰符的产生原因.作用谈起,全面分析static 修饰符的实质. static 的两大作用: 一. ...