UIDevice currentDevice model possible values
NOTE: The below code may not contain all device's string, I'm with other guys are maintaining the same code on GitHub so please take the latest code from there
Objective-C : GitHub/DeviceUtil
Swift : GitHub/DeviceGuru
#include <sys/types.h>
#include <sys/sysctl.h> - (NSString*)hardwareDescription {
NSString *hardware = [self hardwareString];
if ([hardware isEqualToString:@"iPhone1,1"]) return @"iPhone 2G";
if ([hardware isEqualToString:@"iPhone1,2"]) return @"iPhone 3G";
if ([hardware isEqualToString:@"iPhone3,1"]) return @"iPhone 4";
if ([hardware isEqualToString:@"iPhone4,1"]) return @"iPhone 4S";
if ([hardware isEqualToString:@"iPhone5,1"]) return @"iPhone 5";
if ([hardware isEqualToString:@"iPod1,1"]) return @"iPodTouch 1G";
if ([hardware isEqualToString:@"iPod2,1"]) return @"iPodTouch 2G";
if ([hardware isEqualToString:@"iPad1,1"]) return @"iPad";
if ([hardware isEqualToString:@"iPad2,6"]) return @"iPad Mini";
if ([hardware isEqualToString:@"iPad4,1"]) return @"iPad Air WIFI";
//there are lots of other strings too, checkout the github repo
//link is given at the top of this answer if ([hardware isEqualToString:@"i386"]) return @"Simulator";
if ([hardware isEqualToString:@"x86_64"]) return @"Simulator"; return nil;
} - (NSString*)hardwareString {
size_t size = ;
char *hw_machine = malloc(size);
int name[] = {CTL_HW,HW_MACHINE};
sysctl(name, , hw_machine, &size, NULL, );
NSString *hardware = [NSString stringWithUTF8String:hw_machine];
free(hw_machine);
return hardware;
}
原文链接:https://stackoverflow.com/questions/14411075/uidevice-currentdevice-model-possible-values
UIDevice currentDevice model possible values的更多相关文章
- [UIDevice currentDevice].model
iPhone Simulator iPad Simulator iPod touch iPad iPhone
- 获取ios设备系统信息的方法 之 [UIDevice currentDevice]
获取iphone的系统信息使用[UIDevice currentDevice],信息如下: [[UIDevice currentDevice] systemName]:系统名称,如iPhone OS ...
- [UIDevice currentDevice]
获取iphone的系统信息使用[UIDevice currentDevice],信息例如以下: [[UIDevice currentDevice] systemName]:系统名称,如iPhone O ...
- IOS - [UIDevice currentDevice] name/model/localizedMode/systemName/systemVersion...../userInterfaceIdiom
+ (UIDevice *)currentDevice; @property(nonatomic,readonly,retain) NSString *name; // ...
- 调用[[UIDevice currentDevice] userInterfaceIdiom]==UIUserInterfaceIdiomPad判断设备
将模拟器改为Ipad时,调用[[UIDevice currentDevice] userInterfaceIdiom]==UIUserInterfaceIdiomPad判断设备是否为Ipad,但程序并 ...
- 获取iOS系统版本号,慎重使用[[[UIDevice currentDevice] systemVersion] floatValue]——【sdk缺陷】
iOS 最常见的获取系统版本的方法是: [[[UIDevice currentDevice] systemVersion] floatValue] 可是.这个floatValue是不靠谱的,这也算是i ...
- 关于UI_USER_INTERFACE_IDIOM() & UIDevice.model
使用 UI_USER_INTERFACE_IDIOM() 进行区分 (ios 3.2 >=) 无法区分iphone和ipod if (UI_USER_INTERFACE_IDIOM() == U ...
- iOS 整理笔记 获取手机信息(UIDevice、NSBundle、NSLocale)
/* iOS的APP的应用开发的过程中,有时为了bug跟踪或者获取用反馈的需要自动收集用户设备.系统信息.应用信息等等,这些信息方便开发者诊断问题,当然这些信息是用户的非隐私信息,是通过开发ap ...
- iOS - YYAdd对UIDevice的拓展
YYKit中对UIDevice的拓展,accumulate knowledge !!! 首先 #include <sys/socket.h> #include <sys/sysctl ...
随机推荐
- 20155333 2016-2017-2 《Java程序设计》第五周学习总结
20155333 2016-2017-2 <Java程序设计>第五周学习总结 教材学习内容总结 1.使用try.catch语法 与C语言中程序流程和错误处理混在一起不同,Java中把正常流 ...
- 编译hbase-1.2.3源代码
目录 目录 1 1. 约定 1 2. 安装jdk 1 3. 安装maven 1 4. 网络配置 2 4.1. eclipse 3 4.2. maven 3 5. 从hbase官网下载源代码包: 4 6 ...
- android DDMS中的内存监测工具Heap
DDMS中自带的Heap工具可以显示出当前堆内存的情况,分配内存.剩余的内存等信息. 首先是进入DDMS,运行应用,在DDMS的左边区域选中应用的包名,然后点击上方的update heap图标. 点击 ...
- Bellman_ford货币兑换——正权回路判断
POJ1860 题目大意:你在某一点有一些钱,给定你两点之间钱得兑换规则,问你有没有办法使你手里的钱增多.就是想看看转一圈我的钱能不能增多,出现这一点得条件就是有兑换钱得正权回路,所以选择用bellm ...
- Vue2.5 Web App 项目搭建 (TypeScript版)
参考了几位同行的Blogs和StackOverflow上的许多问答,在原来的ng1加TypeScript以及Webpack的经验基础上,搭建了该项目,核心文件如下,供需要的人参考. package.j ...
- App主导现在 HTML5领衔未来
HTML5能够让开发人员构建丰富的基于Web应用程序,使其能在任何设备中使用标准的Web浏览器.很多人认为HTML5将会让App过时.到底App还是HTML5会是谁赢得最后的胜利,在业界也有不少讨论, ...
- linux系统编程之文件与IO(四):目录访问相关系统调用
1. 目录操作相关的系统调用 1.1 mkdir和rmdir系统调用 1.1.1 实例 1.2 chdir, getcwd系统调用 1.2.1 实例 1.3 o ...
- C#使用cplex求解简单线性规划问题(Cplex系列-教程二)
若还未在项目中添加cplex的引用,可以参阅上一篇文章.本文主要介绍利用C#求解线性规划的步骤,对线性规划模型进行数据填充的两种方法,以及一些cplex函数的功能和用法.包括以下几个步骤: 描述 先花 ...
- wpf ,只能窗口调整高度,并且设定最小值。
MaxWidth="900" WindowStyle="ToolWindow" ResizeMode="CanResize" WindowS ...
- 使用node_redis进行redis数据库crud操作
正在学习使用pomelo开发游戏服务器,碰到node.js操作redis,记录一下 假设应用场景是操作一个用户表的数据 引入node_redis库,创建客户端 var redis = require( ...