设备对照表:https://www.theiphonewiki.com/wiki/Models

获取设备和 App 信息代码:

  1. NSLog(@"设备信息如下");
  2. NSLog(@"detailModel(详细型号): %@", [self detailModel]); //detailModel(详细型号): iPhone 6
  3.  
  4. UIDevice *device = [UIDevice currentDevice];
  5. NSLog(@"name(名称): %@", [device name]); //name(名称): My iPhone
  6. NSLog(@"model(型号): %@", [device model]); //model(型号): iPhone
  7. NSLog(@"localizedModel(本地化型号): %@", [device localizedModel]); //localizedModel(本地化型号): iPhone
  8. NSLog(@"systemName(系统名称): %@", [device systemName]); //systemName(系统名称): iPhone OS
  9. NSLog(@"systemVersion(系统版本): %@", [device systemVersion]); //systemVersion(系统版本): 8.3
  10. NSLog(@"identifierForVendor(UUID): %@", [device identifierForVendor]); //identifierForVendor(UUID): <__NSConcreteUUID 0x7ff21b5c8410> 1F61341F-26B2-419C-8B35-75E8F1097CBD
  11.  
  12. NSLog(@"App信息如下");
  13. NSDictionary *dicAppInfo = [[NSBundle mainBundle] infoDictionary];
  14. NSString *shortVersion = [dicAppInfo objectForKey:@"CFBundleShortVersionString"];
  15. NSString *buildVersion = [dicAppInfo objectForKey:@"CFBundleVersion"];
  16. NSString *name = [dicAppInfo objectForKey:@"CFBundleName"];
  17. NSString *displayName = [dicAppInfo objectForKey:@"CFBundleDisplayName"];
  18. NSString *identifier = [dicAppInfo objectForKey:@"CFBundleIdentifier"];
  19. NSString *minimumOSVersion = [dicAppInfo objectForKey:@"MinimumOSVersion"];
  20.  
  21. NSLog(@"CFBundleShortVersionString(Version版本): %@", shortVersion); //CFBundleShortVersionString(Version版本): 1.0
  22. NSLog(@"CFBundleVersion(Build版本): %@", buildVersion); //CFBundleVersion(Build版本): 1
  23. NSLog(@"CFBundleName(名称): %@", name); //CFBundleName(名称): FirstBook187
  24. NSLog(@"CFBundleDisplayName(显示名称): %@", displayName); //CFBundleDisplayName(显示名称): (null);默认为null,因为Info.plist文件默认不会添加“Bundle display name”,而App的显示名称优先级来说:CFBundleDisplayName>CFBundleName,即CFBundleDisplayName不存在的情况下,就是显示CFBundleName
  25. NSLog(@"CFBundleIdentifier(标识符): %@", identifier); //CFBundleIdentifier(标识符): com.kenmu.FirstBook187
  26. NSLog(@"MinimumOSVersion(兼容的最小操作系统版本): %@", minimumOSVersion); //MinimumOSVersion(兼容的最小操作系统版本): 7.0
  27.  
  28. CFShow((__bridge CFTypeRef)(dicAppInfo)); //通过CFShow可以输出dicAppInfo的所有键值对信息;真机输出的信息比模拟器多

获取设备详细型号的代码:

  1. #import "sys/utsname.h"
  2.  
  3. - (NSString *)detailModel {
  4. //{代号 : 详细型号}
  5. NSDictionary *dicDeviceInfo = @{ @"x86_64" : @"Simulator",
  6. @"i386" : @"Simulator",
  7. @"iPhone7,2" : @"iPhone 6",
  8. @"iPhone7,1" : @"iPhone 6 Plus",
  9. @"iPhone6,2" : @"iPhone 5s (Global)",
  10. @"iPhone6,1" : @"iPhone 5s (GSM)",
  11. @"iPhone5,4" : @"iPhone 5c (Global)",
  12. @"iPhone5,3" : @"iPhone 5c (GSM)",
  13. @"iPhone5,2" : @"iPhone 5 (GSM+CDMA)",
  14. @"iPhone5,1" : @"iPhone 5 (GSM)",
  15. @"iPhone4,1" : @"iPhone 4S",
  16. @"iPhone3,3" : @"iPhone 4 (CDMA)",
  17. @"iPhone3,2" : @"iPhone 4 (GSM Rev A)",
  18. @"iPhone3,1" : @"iPhone 4 (GSM)",
  19. @"iPhone2,1" : @"iPhone 3GS",
  20. @"iPhone1,2" : @"iPhone 3G",
  21. @"iPhone1,1" : @"iPhone 2G",
  22.  
  23. @"iPad5,4" : @"iPad Air 2",
  24. @"iPad5,3" : @"iPad Air 2",
  25. @"iPad4,3" : @"iPad Air",
  26. @"iPad4,2" : @"iPad Air",
  27. @"iPad3,6" : @"iPad 4 (GSM+CDMA)",
  28. @"iPad3,5" : @"iPad 4 (GSM)",
  29. @"iPad3,4" : @"iPad 4 (WiFi)",
  30. @"iPad3,3" : @"iPad 3 (GSM)",
  31. @"iPad3,2" : @"iPad 3 (GSM+CDMA)",
  32. @"iPad3,1" : @"iPad 3 (WiFi)",
  33. @"iPad2,4" : @"iPad 2 (WiFi + New Chip)",
  34. @"iPad2,3" : @"iPad 2 (CDMA)",
  35. @"iPad2,2" : @"iPad 2 (GSM)",
  36. @"iPad2,1" : @"iPad 2 (WiFi)",
  37. @"iPad1,1" : @"iPad",
  38.  
  39. @"iPad4,9" : @"iPad mini 3",
  40. @"iPad4,8" : @"iPad mini 3",
  41. @"iPad4,7" : @"iPad mini 3",
  42. @"iPad4,6" : @"iPad mini 2",
  43. @"iPad4,5" : @"iPad mini 2",
  44. @"iPad4,4" : @"iPad mini 2",
  45. @"iPad2,7" : @"iPad mini 1G (WiFi)",
  46. @"iPad2,6" : @"iPad mini 1G (GSM)",
  47. @"iPad2,5" : @"iPad mini 1G (GSM+CDMA)",
  48.  
  49. @"iPod5,1" : @"iPod touch 5G",
  50. @"iPod4,1" : @"iPod touch 4G",
  51. @"iPod3,1" : @"iPod touch 3G",
  52. @"iPod2,1" : @"iPod touch 2G",
  53. @"iPod1,1" : @"iPod touch",
  54.  
  55. @"Watch1,2" : @"Apple Watch",
  56. @"Watch1,1" : @"Apple Watch",
  57.  
  58. @"AppleTV3,2" : @"Apple TV 3G",
  59. @"AppleTV3,1" : @"Apple TV 3G",
  60. @"AppleTV2,1" : @"Apple TV 2G" };
  61. struct utsname systemInfo; //这是LINUX系统放硬件版本的信息的地方;所以需要导入包sys/utsname.h
  62. uname(&systemInfo);
  63. NSString *strMachineCode = [NSString stringWithCString:systemInfo.machine encoding:NSUTF8StringEncoding];
  64.  
  65. //也可以用allKeys和indexOfObject结合,来判断是否此设备代号存在,再获取它对应的详细型号
  66. NSString *strDetailModel = [dicDeviceInfo objectForKey:strMachineCode];
  67. if(!strDetailModel) {
  68. strDetailModel = @"Unknown Device";
  69. }
  70. return strDetailModel;
  71. }

结果:

  1. -- ::10.315 FirstBook187[:] 设备信息如下
  2. -- ::10.316 FirstBook187[:] detailModel(详细型号): Simulator
  3. -- ::10.316 FirstBook187[:] name(名称): iPhone Simulator
  4. -- ::10.316 FirstBook187[:] model(型号): iPhone Simulator
  5. -- ::10.316 FirstBook187[:] localizedModel(本地化型号): iPhone Simulator
  6. -- ::10.317 FirstBook187[:] systemName(系统名称): iPhone OS
  7. -- ::10.317 FirstBook187[:] systemVersion(系统版本): 8.3
  8. -- ::10.317 FirstBook187[:] identifierForVendor(UUID): <__NSConcreteUUID 0x7fbc5365b290> 1F61341F-26B2-419C-8B35-75E8F1097CBD
  9. -- ::10.318 FirstBook187[:] App信息如下
  10. -- ::10.318 FirstBook187[:] CFBundleShortVersionString(Version版本): 1.0
  11. -- ::10.318 FirstBook187[:] CFBundleVersion(Build版本):
  12. -- ::10.318 FirstBook187[:] CFBundleName(名称): FirstBook187
  13. -- ::10.318 FirstBook187[:] CFBundleDisplayName(显示名称): (null)
  14. -- ::10.376 FirstBook187[:] CFBundleIdentifier(标识符): com.kenmu.FirstBook187
  15. -- ::10.376 FirstBook187[:] MinimumOSVersion(兼容的最小操作系统版本): 7.0
  16. <CFBasicHash 0x7fbc53504d60 [0x101ad8180]>{type = mutable dict, count = ,
  17. entries =>
  18. : <CFString 0x7fbc535048d0 [0x101ad8180]>{contents = "CFBundleName"} = <CFString 0x7fbc53504d40 [0x101ad8180]>{contents = "FirstBook187"}
  19. : <CFString 0x7fbc535030c0 [0x101ad8180]>{contents = "DTSDKName"} = <CFString 0x7fbc53504c90 [0x101ad8180]>{contents = "iphonesimulator8.3"}
  20. : <CFString 0x101ab0b40 [0x101ad8180]>{contents = "CFBundleInfoPlistURL"} = <CFURL 0x7fbc53503e70 [0x101ad8180]>{string = Info.plist, encoding =
  21. base = <CFURL 0x7fbc53503610 [0x101ad8180]>{string = file:///Users/Kenmu/Library/Developer/CoreSimulator/Devices/85240D3B-7BE5-4AF1-A570-F2116C2B7979/data/Containers/Bundle/Application/7FCB8335-0BD8-4A70-B0CC-17D8512FA327/FirstBook187.app/, encoding = 134217984, base = (null)}}
  22. : <CFString 0x101ab0b80 [0x101ad8180]>{contents = "CFBundleNumericVersion"} = <CFNumber 0xb000000010080002 [0x101ad8180]>{value = +, type = kCFNumberSInt32Type}
  23. : <CFString 0x7fbc535046c0 [0x101ad8180]>{contents = "UILaunchStoryboardName"} = <CFString 0x7fbc53504a00 [0x101ad8180]>{contents = "LaunchScreen"}
  24. : <CFString 0x7fbc53504880 [0x101ad8180]>{contents = "CFBundleDevelopmentRegion"} = <CFString 0x7fbc53504cc0 [0x101ad8180]>{contents = "en"}
  25. : <CFString 0x7fbc53503e00 [0x101ad8180]>{contents = "CFBundleVersion"} = <CFString 0x7fbc535049e0 [0x101ad8180]>{contents = ""}
  26. : <CFString 0x7fbc53503e40 [0x101ad8180]>{contents = "DTPlatformName"} = <CFString 0x7fbc53504c60 [0x101ad8180]>{contents = "iphonesimulator"}
  27. : <CFString 0x7fbc53504850 [0x101ad8180]>{contents = "CFBundlePackageType"} = <CFString 0x7fbc53504c40 [0x101ad8180]>{contents = "APPL"}
  28. : <CFString 0x7fbc53503dd0 [0x101ad8180]>{contents = "UIMainStoryboardFile"} = <CFString 0x7fbc535049c0 [0x101ad8180]>{contents = "Main"}
  29. : <CFString 0x7fbc535047f0 [0x101ad8180]>{contents = "CFBundleSupportedPlatforms"} = <CFArray 0x7fbc53504bc0 [0x101ad8180]>{type = mutable-small, count = , values = (
  30. : <CFString 0x7fbc53504b90 [0x101ad8180]>{contents = "iPhoneSimulator"}
  31. )}
  32. : <CFString 0x7fbc53504750 [0x101ad8180]>{contents = "CFBundleShortVersionString"} = <CFString 0x7fbc53504a40 [0x101ad8180]>{contents = "1.0"}
  33. : <CFString 0x7fbc53503da0 [0x101ad8180]>{contents = "CFBundleInfoDictionaryVersion"} = <CFString 0x7fbc535049a0 [0x101ad8180]>{contents = "6.0"}
  34. : <CFString 0x7fbc53503bb0 [0x101ad8180]>{contents = "UIRequiredDeviceCapabilities"} = <CFArray 0x7fbc53504910 [0x101ad8180]>{type = mutable-small, count = , values = (
  35. : <CFString 0x7fbc535048f0 [0x101ad8180]>{contents = "armv7"}
  36. )}
  37. : <CFString 0x7fbc535046f0 [0x101ad8180]>{contents = "CFBundleExecutable"} = <CFString 0x7fbc53504a20 [0x101ad8180]>{contents = "FirstBook187"}
  38. : <CFString 0x7fbc535047c0 [0x101ad8180]>{contents = "MinimumOSVersion"} = <CFString 0x7fbc53504b70 [0x101ad8180]>{contents = "7.0"}
  39. : <CFString 0x7fbc53503d70 [0x101ad8180]>{contents = "CFBundleIdentifier"} = <CFString 0x7fbc53504970 [0x101ad8180]>{contents = "com.kenmu.FirstBook187"}
  40. : <CFString 0x7fbc535048b0 [0x101ad8180]>{contents = "UIDeviceFamily"} = <CFArray 0x7fbc53504ce0 [0x101ad8180]>{type = mutable-small, count = , values = (
  41. : <CFNumber 0xb000000000000013 [0x101ad8180]>{value = +, type = kCFNumberSInt64Type}
  42. )}
  43. : <CFString 0x7fbc53504820 [0x101ad8180]>{contents = "CFBundleSignature"} = <CFString 0x7fbc53504c20 [0x101ad8180]>{contents = "????"}
  44. : <CFString 0x7fbc53504720 [0x101ad8180]>{contents = "LSRequiresIPhoneOS"} = <CFBoolean 0x101ad8bf0 [0x101ad8180]>{value = true}
  45. : <CFString 0x7fbc53504780 [0x101ad8180]>{contents = "UISupportedInterfaceOrientations"} = <CFArray 0x7fbc53504b10 [0x101ad8180]>{type = mutable-small, count = , values = (
  46. : <CFString 0x7fbc53504a60 [0x101ad8180]>{contents = "UIInterfaceOrientationPortrait"}
  47. : <CFString 0x7fbc53504a90 [0x101ad8180]>{contents = "UIInterfaceOrientationLandscapeLeft"}
  48. : <CFString 0x7fbc53504ad0 [0x101ad8180]>{contents = "UIInterfaceOrientationLandscapeRight"}
  49. )}
  50. }

获取设备和 App 信息的更多相关文章

  1. 获取设备、APP的一些信息

    获取设备的一些信息: UIDevice *device = [UIDevice currentDevice]; @property(nonatomic,readonly,strong) NSStrin ...

  2. Cordova各个插件使用介绍系列(六)—$cordovaDevice获取设备的相关信息

    详情请看:Cordova各个插件使用介绍系列(六)—$cordovaDevice获取设备的相关信息 在项目中需要获取到当前设备,例如手机的ID,联网状态,等,然后这个Cordova里有这个插件可以用, ...

  3. ios 获取设备相关的信息

    .获取设备的信息 UIDevice *device = [[UIDevice alloc] int]; NSString *name = device.name; //获取设备所有者的名称 NSStr ...

  4. iOS ---------- 获取设备的各种信息

    一.目录结构: 获取屏幕宽度与高度 获取设备版本号 获取iPhone名称 获取app版本号 获取电池电量 获取当前系统名称 获取当前系统版本号 获取通用的唯一识别码UUID 获取当前设备IP 获取总内 ...

  5. iOS 获取设备的各种信息的方法

    一.目录结构: 获取屏幕宽度与高度 获取设备版本号 获取iPhone名称 获取app版本号 获取电池电量 获取当前系统名称 获取当前系统版本号 获取通用的唯一识别码UUID 获取当前设备IP 获取总内 ...

  6. Android开发之获取设备的屏幕信息和px dp之间的转换

    DisplayMetrics metric = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(metr ...

  7. snmp获取设备相关管理信息

    在本文中,作者将向我们展示如何用snmp代理监视网络设备,甚至发送软件警告. 网络上很多代理在为我们服务.只要我们开启UDP/161,162端口,这些代理就会以Management Informati ...

  8. C#:获取设备电量相关信息

    更多资源:http://denghejun.github.io [DllImport("kernel32.dll",EntryPoint="GetSystemPowerS ...

  9. iOS 随笔小技巧 弱self 打印当前类行数列数,多人开发自动适配pch地址,获取设备uid的信息

    $(SRCROOT)/PrefixHeader.pch自动适配pch地址 __weak __block typeof(self) weakself = self; __weak typeof(self ...

随机推荐

  1. iOS 使用Masonry介绍与使用实践:快速上手Autolayout

    介绍 Masonry 源码:https://github.com/Masonry/Masonry Masonry是一个轻量级的布局框架 拥有自己的描述语法 采用更优雅的链式语法封装自动布局 简洁明了 ...

  2. DFI、DPI技术

    废话: 因为xxoo的缘故接触到这个设备.但是就是单纯的去看并没有去研究它是个啥玩意.刚才无聊就百度科普了一波. DFI以及DPI简单通俗以自己的理解来将就是网络带宽的一种检测技术.既然是检测技术也就 ...

  3. CLR笔记-枚举类型

    class Program { static void Main(string[] args) { Color color = Color.Red; Console.WriteLine(color.T ...

  4. linux下修改tomcat使用的jdk版本

    遇到一种情况,就是linux上好像掉文件了,JDK的目录下没有了,具体问题还不清楚,不过要赶紧修复,不能影响其他程序的运行. 结构重新安装了JDK,tomcat还是启动失败,看l启动日志发现没找到还是 ...

  5. [Linux实用工具]Ubuntu环境下SSH的安装及使用

    SSH分为客户端和服务端. 服务端是一个守护进程,一般是sshd进程,在后台运行并响应来自客户端的请求.提供了对远程请求的处理,一般包括公共密钥认证.密钥交换.对称密钥加密和非安全连接. 客户端一般是 ...

  6. <【彼得林奇 投资选股智慧全集】>读书笔记

    书在这里 投资公司而不是投资股市 好公司的股票迟早会有良好的表现 构建投资组合,降低投资风险 股票只是表象,上市公司才是实质,你要做的,就是搞清楚企业状况 要投资与企业,而不是投机于股市 评价股票的价 ...

  7. git commit 合并

    日常 git 管理代码的时候,经常因为因为一些小的代码改动而进行一次 git commit , 但是这样造成的后果就是小的 git commit 很多很杂. 今天特意的研究了一些 git commit ...

  8. OpenCV 图像处理的各种滤镜效果实现

    引自:https://blog.csdn.net/column/details/stylizefliter.html 学习OpenCV:滤镜系列(15)——羽化(模糊边缘) 在PHOTOSHOP里,羽 ...

  9. Lamda表达式的参数捕获,太酷了

    lamda表达式有了参数捕获这个功能,让Action这个委托变得无所不能.Action委托就是无参数,无返回值的一个代理类型. 它只能对应于下面这种类型的函数声明. public void Funct ...

  10. GCC编译错误小结

    gcc编译时对’xxxx’未定义的引用问题可能错误 错误一: 没有实现xxxx 错误二: c++引用c语言so库,但是so库头文件没有extern "C" 错误三: 检查各个共享库 ...