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的更多相关文章

  1. [UIDevice currentDevice].model

    iPhone Simulator iPad Simulator iPod touch iPad iPhone  

  2. 获取ios设备系统信息的方法 之 [UIDevice currentDevice]

    获取iphone的系统信息使用[UIDevice currentDevice],信息如下: [[UIDevice currentDevice] systemName]:系统名称,如iPhone OS ...

  3. [UIDevice currentDevice]

    获取iphone的系统信息使用[UIDevice currentDevice],信息例如以下: [[UIDevice currentDevice] systemName]:系统名称,如iPhone O ...

  4. IOS - [UIDevice currentDevice] name/model/localizedMode/systemName/systemVersion...../userInterfaceIdiom

    + (UIDevice *)currentDevice; @property(nonatomic,readonly,retain) NSString    *name;              // ...

  5. 调用[[UIDevice currentDevice] userInterfaceIdiom]==UIUserInterfaceIdiomPad判断设备

    将模拟器改为Ipad时,调用[[UIDevice currentDevice] userInterfaceIdiom]==UIUserInterfaceIdiomPad判断设备是否为Ipad,但程序并 ...

  6. 获取iOS系统版本号,慎重使用[[[UIDevice currentDevice] systemVersion] floatValue]——【sdk缺陷】

    iOS 最常见的获取系统版本的方法是: [[[UIDevice currentDevice] systemVersion] floatValue] 可是.这个floatValue是不靠谱的,这也算是i ...

  7. 关于UI_USER_INTERFACE_IDIOM() & UIDevice.model

    使用 UI_USER_INTERFACE_IDIOM() 进行区分 (ios 3.2 >=) 无法区分iphone和ipod if (UI_USER_INTERFACE_IDIOM() == U ...

  8. iOS 整理笔记 获取手机信息(UIDevice、NSBundle、NSLocale)

    /*    iOS的APP的应用开发的过程中,有时为了bug跟踪或者获取用反馈的需要自动收集用户设备.系统信息.应用信息等等,这些信息方便开发者诊断问题,当然这些信息是用户的非隐私信息,是通过开发ap ...

  9. iOS - YYAdd对UIDevice的拓展

    YYKit中对UIDevice的拓展,accumulate knowledge !!! 首先 #include <sys/socket.h> #include <sys/sysctl ...

随机推荐

  1. 更新vs2017 15.9.2后,在指定-T v141_xp情况下载编译会报下面warning MSB8051

    更新vs2017 15.9.2后,在指定-T v141_xp情况下载编译会报下面warning: C:\Program Files (x86)\Microsoft Visual Studio\2017 ...

  2. 今天研究了一下手机通信录管理系统(C语言)

    题目:手机通信录管理系统 一.题目要求 二.需求分析 三.设计步骤/编写代码 四.上机/运行结果 五.总结 一.题目要求 模拟手机通信录管理系统,实现对手机中的通信录进行管理操作.功能要求: (1)查 ...

  3. 可视化 linux 无法启动eclipse 报错No java virtual machine

    点击eclipse的时候会产生这个 解决方案: (1)找到eclipse的安装目录(我这个是远程连接) 注意: 点击这里可以进入命令行编辑模式 点开后 (2)给文件授权(默认是只读的) (3)对文件进 ...

  4. Python+Android开发

    1 下载Scripting Layer for Android (SL4A) Scripting Layer for Android (SL4A) 是一个开源项目,目标是为android系统提供脚本语 ...

  5. python实现base64算法加密

    python本身有base64加密的模块,不过是用C写的,封装成了.so文件,无法查看源码,本着学习的心态,自己实现了一遍,算法 原理参考 浅谈Base64编码算法. 代码如下: # coding:u ...

  6. cmder简单使用

    window命令行的替代工具cmder.至于为什么要找个替代cmd的工具,你懂得! 一 官网下载 http://gooseberrycreative.com/cmder/ 二 安装 1 直接解压 2 ...

  7. application cache 应用缓存

    这些应用还是要自己实现一遍,否则真不知道哪里会出问题. 客户端: <!DOCTYPE html> <html manifest = 'demo.appcache'> <h ...

  8. Spring Boot 2 实践记录之 使用 Powermock、Mockito 对 UUID 进行 mock 单元测试

    由于注册时,需要对输入的密码进行加密,使用到了 UUID.sha1.md 等算法.在单元测试时,使用到了 Powermock,记录如下. 先看下加密算法: import org.apache.comm ...

  9. 给IDistributedCache新增了扩展方法GetOrCreate、GetOrCreateAsync

    public static class DistributedCacheExtensions { public static TItem GetOrCreate<TItem>(this I ...

  10. 导出excle错误

    导出excel时出现下面的错误: 类型“GridView”的控件“SimpleForm1_ContentPanel2_GVD_List”必须放在具有 runat=server 的窗体标记内. 可以在对 ...