获取设备和 App 信息
设备对照表:https://www.theiphonewiki.com/wiki/Models
获取设备和 App 信息代码:
NSLog(@"设备信息如下");
NSLog(@"detailModel(详细型号): %@", [self detailModel]); //detailModel(详细型号): iPhone 6 UIDevice *device = [UIDevice currentDevice];
NSLog(@"name(名称): %@", [device name]); //name(名称): My iPhone
NSLog(@"model(型号): %@", [device model]); //model(型号): iPhone
NSLog(@"localizedModel(本地化型号): %@", [device localizedModel]); //localizedModel(本地化型号): iPhone
NSLog(@"systemName(系统名称): %@", [device systemName]); //systemName(系统名称): iPhone OS
NSLog(@"systemVersion(系统版本): %@", [device systemVersion]); //systemVersion(系统版本): 8.3
NSLog(@"identifierForVendor(UUID): %@", [device identifierForVendor]); //identifierForVendor(UUID): <__NSConcreteUUID 0x7ff21b5c8410> 1F61341F-26B2-419C-8B35-75E8F1097CBD NSLog(@"App信息如下");
NSDictionary *dicAppInfo = [[NSBundle mainBundle] infoDictionary];
NSString *shortVersion = [dicAppInfo objectForKey:@"CFBundleShortVersionString"];
NSString *buildVersion = [dicAppInfo objectForKey:@"CFBundleVersion"];
NSString *name = [dicAppInfo objectForKey:@"CFBundleName"];
NSString *displayName = [dicAppInfo objectForKey:@"CFBundleDisplayName"];
NSString *identifier = [dicAppInfo objectForKey:@"CFBundleIdentifier"];
NSString *minimumOSVersion = [dicAppInfo objectForKey:@"MinimumOSVersion"]; NSLog(@"CFBundleShortVersionString(Version版本): %@", shortVersion); //CFBundleShortVersionString(Version版本): 1.0
NSLog(@"CFBundleVersion(Build版本): %@", buildVersion); //CFBundleVersion(Build版本): 1
NSLog(@"CFBundleName(名称): %@", name); //CFBundleName(名称): FirstBook187
NSLog(@"CFBundleDisplayName(显示名称): %@", displayName); //CFBundleDisplayName(显示名称): (null);默认为null,因为Info.plist文件默认不会添加“Bundle display name”,而App的显示名称优先级来说:CFBundleDisplayName>CFBundleName,即CFBundleDisplayName不存在的情况下,就是显示CFBundleName
NSLog(@"CFBundleIdentifier(标识符): %@", identifier); //CFBundleIdentifier(标识符): com.kenmu.FirstBook187
NSLog(@"MinimumOSVersion(兼容的最小操作系统版本): %@", minimumOSVersion); //MinimumOSVersion(兼容的最小操作系统版本): 7.0 CFShow((__bridge CFTypeRef)(dicAppInfo)); //通过CFShow可以输出dicAppInfo的所有键值对信息;真机输出的信息比模拟器多
获取设备详细型号的代码:
#import "sys/utsname.h"
- (NSString *)detailModel {
//{代号 : 详细型号}
NSDictionary *dicDeviceInfo = @{ @"x86_64" : @"Simulator",
@"i386" : @"Simulator",
@"iPhone7,2" : @"iPhone 6",
@"iPhone7,1" : @"iPhone 6 Plus",
@"iPhone6,2" : @"iPhone 5s (Global)",
@"iPhone6,1" : @"iPhone 5s (GSM)",
@"iPhone5,4" : @"iPhone 5c (Global)",
@"iPhone5,3" : @"iPhone 5c (GSM)",
@"iPhone5,2" : @"iPhone 5 (GSM+CDMA)",
@"iPhone5,1" : @"iPhone 5 (GSM)",
@"iPhone4,1" : @"iPhone 4S",
@"iPhone3,3" : @"iPhone 4 (CDMA)",
@"iPhone3,2" : @"iPhone 4 (GSM Rev A)",
@"iPhone3,1" : @"iPhone 4 (GSM)",
@"iPhone2,1" : @"iPhone 3GS",
@"iPhone1,2" : @"iPhone 3G",
@"iPhone1,1" : @"iPhone 2G",
@"iPad5,4" : @"iPad Air 2",
@"iPad5,3" : @"iPad Air 2",
@"iPad4,3" : @"iPad Air",
@"iPad4,2" : @"iPad Air",
@"iPad3,6" : @"iPad 4 (GSM+CDMA)",
@"iPad3,5" : @"iPad 4 (GSM)",
@"iPad3,4" : @"iPad 4 (WiFi)",
@"iPad3,3" : @"iPad 3 (GSM)",
@"iPad3,2" : @"iPad 3 (GSM+CDMA)",
@"iPad3,1" : @"iPad 3 (WiFi)",
@"iPad2,4" : @"iPad 2 (WiFi + New Chip)",
@"iPad2,3" : @"iPad 2 (CDMA)",
@"iPad2,2" : @"iPad 2 (GSM)",
@"iPad2,1" : @"iPad 2 (WiFi)",
@"iPad1,1" : @"iPad",
@"iPad4,9" : @"iPad mini 3",
@"iPad4,8" : @"iPad mini 3",
@"iPad4,7" : @"iPad mini 3",
@"iPad4,6" : @"iPad mini 2",
@"iPad4,5" : @"iPad mini 2",
@"iPad4,4" : @"iPad mini 2",
@"iPad2,7" : @"iPad mini 1G (WiFi)",
@"iPad2,6" : @"iPad mini 1G (GSM)",
@"iPad2,5" : @"iPad mini 1G (GSM+CDMA)",
@"iPod5,1" : @"iPod touch 5G",
@"iPod4,1" : @"iPod touch 4G",
@"iPod3,1" : @"iPod touch 3G",
@"iPod2,1" : @"iPod touch 2G",
@"iPod1,1" : @"iPod touch",
@"Watch1,2" : @"Apple Watch",
@"Watch1,1" : @"Apple Watch",
@"AppleTV3,2" : @"Apple TV 3G",
@"AppleTV3,1" : @"Apple TV 3G",
@"AppleTV2,1" : @"Apple TV 2G" };
struct utsname systemInfo; //这是LINUX系统放硬件版本的信息的地方;所以需要导入包sys/utsname.h
uname(&systemInfo);
NSString *strMachineCode = [NSString stringWithCString:systemInfo.machine encoding:NSUTF8StringEncoding];
//也可以用allKeys和indexOfObject结合,来判断是否此设备代号存在,再获取它对应的详细型号
NSString *strDetailModel = [dicDeviceInfo objectForKey:strMachineCode];
if(!strDetailModel) {
strDetailModel = @"Unknown Device";
}
return strDetailModel;
}
结果:
-- ::10.315 FirstBook187[:] 设备信息如下
-- ::10.316 FirstBook187[:] detailModel(详细型号): Simulator
-- ::10.316 FirstBook187[:] name(名称): iPhone Simulator
-- ::10.316 FirstBook187[:] model(型号): iPhone Simulator
-- ::10.316 FirstBook187[:] localizedModel(本地化型号): iPhone Simulator
-- ::10.317 FirstBook187[:] systemName(系统名称): iPhone OS
-- ::10.317 FirstBook187[:] systemVersion(系统版本): 8.3
-- ::10.317 FirstBook187[:] identifierForVendor(UUID): <__NSConcreteUUID 0x7fbc5365b290> 1F61341F-26B2-419C-8B35-75E8F1097CBD
-- ::10.318 FirstBook187[:] App信息如下
-- ::10.318 FirstBook187[:] CFBundleShortVersionString(Version版本): 1.0
-- ::10.318 FirstBook187[:] CFBundleVersion(Build版本):
-- ::10.318 FirstBook187[:] CFBundleName(名称): FirstBook187
-- ::10.318 FirstBook187[:] CFBundleDisplayName(显示名称): (null)
-- ::10.376 FirstBook187[:] CFBundleIdentifier(标识符): com.kenmu.FirstBook187
-- ::10.376 FirstBook187[:] MinimumOSVersion(兼容的最小操作系统版本): 7.0
<CFBasicHash 0x7fbc53504d60 [0x101ad8180]>{type = mutable dict, count = ,
entries =>
: <CFString 0x7fbc535048d0 [0x101ad8180]>{contents = "CFBundleName"} = <CFString 0x7fbc53504d40 [0x101ad8180]>{contents = "FirstBook187"}
: <CFString 0x7fbc535030c0 [0x101ad8180]>{contents = "DTSDKName"} = <CFString 0x7fbc53504c90 [0x101ad8180]>{contents = "iphonesimulator8.3"}
: <CFString 0x101ab0b40 [0x101ad8180]>{contents = "CFBundleInfoPlistURL"} = <CFURL 0x7fbc53503e70 [0x101ad8180]>{string = Info.plist, encoding =
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)}}
: <CFString 0x101ab0b80 [0x101ad8180]>{contents = "CFBundleNumericVersion"} = <CFNumber 0xb000000010080002 [0x101ad8180]>{value = +, type = kCFNumberSInt32Type}
: <CFString 0x7fbc535046c0 [0x101ad8180]>{contents = "UILaunchStoryboardName"} = <CFString 0x7fbc53504a00 [0x101ad8180]>{contents = "LaunchScreen"}
: <CFString 0x7fbc53504880 [0x101ad8180]>{contents = "CFBundleDevelopmentRegion"} = <CFString 0x7fbc53504cc0 [0x101ad8180]>{contents = "en"}
: <CFString 0x7fbc53503e00 [0x101ad8180]>{contents = "CFBundleVersion"} = <CFString 0x7fbc535049e0 [0x101ad8180]>{contents = ""}
: <CFString 0x7fbc53503e40 [0x101ad8180]>{contents = "DTPlatformName"} = <CFString 0x7fbc53504c60 [0x101ad8180]>{contents = "iphonesimulator"}
: <CFString 0x7fbc53504850 [0x101ad8180]>{contents = "CFBundlePackageType"} = <CFString 0x7fbc53504c40 [0x101ad8180]>{contents = "APPL"}
: <CFString 0x7fbc53503dd0 [0x101ad8180]>{contents = "UIMainStoryboardFile"} = <CFString 0x7fbc535049c0 [0x101ad8180]>{contents = "Main"}
: <CFString 0x7fbc535047f0 [0x101ad8180]>{contents = "CFBundleSupportedPlatforms"} = <CFArray 0x7fbc53504bc0 [0x101ad8180]>{type = mutable-small, count = , values = (
: <CFString 0x7fbc53504b90 [0x101ad8180]>{contents = "iPhoneSimulator"}
)}
: <CFString 0x7fbc53504750 [0x101ad8180]>{contents = "CFBundleShortVersionString"} = <CFString 0x7fbc53504a40 [0x101ad8180]>{contents = "1.0"}
: <CFString 0x7fbc53503da0 [0x101ad8180]>{contents = "CFBundleInfoDictionaryVersion"} = <CFString 0x7fbc535049a0 [0x101ad8180]>{contents = "6.0"}
: <CFString 0x7fbc53503bb0 [0x101ad8180]>{contents = "UIRequiredDeviceCapabilities"} = <CFArray 0x7fbc53504910 [0x101ad8180]>{type = mutable-small, count = , values = (
: <CFString 0x7fbc535048f0 [0x101ad8180]>{contents = "armv7"}
)}
: <CFString 0x7fbc535046f0 [0x101ad8180]>{contents = "CFBundleExecutable"} = <CFString 0x7fbc53504a20 [0x101ad8180]>{contents = "FirstBook187"}
: <CFString 0x7fbc535047c0 [0x101ad8180]>{contents = "MinimumOSVersion"} = <CFString 0x7fbc53504b70 [0x101ad8180]>{contents = "7.0"}
: <CFString 0x7fbc53503d70 [0x101ad8180]>{contents = "CFBundleIdentifier"} = <CFString 0x7fbc53504970 [0x101ad8180]>{contents = "com.kenmu.FirstBook187"}
: <CFString 0x7fbc535048b0 [0x101ad8180]>{contents = "UIDeviceFamily"} = <CFArray 0x7fbc53504ce0 [0x101ad8180]>{type = mutable-small, count = , values = (
: <CFNumber 0xb000000000000013 [0x101ad8180]>{value = +, type = kCFNumberSInt64Type}
)}
: <CFString 0x7fbc53504820 [0x101ad8180]>{contents = "CFBundleSignature"} = <CFString 0x7fbc53504c20 [0x101ad8180]>{contents = "????"}
: <CFString 0x7fbc53504720 [0x101ad8180]>{contents = "LSRequiresIPhoneOS"} = <CFBoolean 0x101ad8bf0 [0x101ad8180]>{value = true}
: <CFString 0x7fbc53504780 [0x101ad8180]>{contents = "UISupportedInterfaceOrientations"} = <CFArray 0x7fbc53504b10 [0x101ad8180]>{type = mutable-small, count = , values = (
: <CFString 0x7fbc53504a60 [0x101ad8180]>{contents = "UIInterfaceOrientationPortrait"}
: <CFString 0x7fbc53504a90 [0x101ad8180]>{contents = "UIInterfaceOrientationLandscapeLeft"}
: <CFString 0x7fbc53504ad0 [0x101ad8180]>{contents = "UIInterfaceOrientationLandscapeRight"}
)}
}
获取设备和 App 信息的更多相关文章
- 获取设备、APP的一些信息
获取设备的一些信息: UIDevice *device = [UIDevice currentDevice]; @property(nonatomic,readonly,strong) NSStrin ...
- Cordova各个插件使用介绍系列(六)—$cordovaDevice获取设备的相关信息
详情请看:Cordova各个插件使用介绍系列(六)—$cordovaDevice获取设备的相关信息 在项目中需要获取到当前设备,例如手机的ID,联网状态,等,然后这个Cordova里有这个插件可以用, ...
- ios 获取设备相关的信息
.获取设备的信息 UIDevice *device = [[UIDevice alloc] int]; NSString *name = device.name; //获取设备所有者的名称 NSStr ...
- iOS ---------- 获取设备的各种信息
一.目录结构: 获取屏幕宽度与高度 获取设备版本号 获取iPhone名称 获取app版本号 获取电池电量 获取当前系统名称 获取当前系统版本号 获取通用的唯一识别码UUID 获取当前设备IP 获取总内 ...
- iOS 获取设备的各种信息的方法
一.目录结构: 获取屏幕宽度与高度 获取设备版本号 获取iPhone名称 获取app版本号 获取电池电量 获取当前系统名称 获取当前系统版本号 获取通用的唯一识别码UUID 获取当前设备IP 获取总内 ...
- Android开发之获取设备的屏幕信息和px dp之间的转换
DisplayMetrics metric = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(metr ...
- snmp获取设备相关管理信息
在本文中,作者将向我们展示如何用snmp代理监视网络设备,甚至发送软件警告. 网络上很多代理在为我们服务.只要我们开启UDP/161,162端口,这些代理就会以Management Informati ...
- C#:获取设备电量相关信息
更多资源:http://denghejun.github.io [DllImport("kernel32.dll",EntryPoint="GetSystemPowerS ...
- iOS 随笔小技巧 弱self 打印当前类行数列数,多人开发自动适配pch地址,获取设备uid的信息
$(SRCROOT)/PrefixHeader.pch自动适配pch地址 __weak __block typeof(self) weakself = self; __weak typeof(self ...
随机推荐
- struts工作原理不错的解释___
Struts 使用 Model 2 架构.Struts 的ActionServlet 控制导航流.其他Struts 类,比如Action, 用来访问业务逻辑类.当 ActionServlet 从容器接 ...
- Tomcat的JVM和连接数设置
Tomcat的JVM和连接数设置 Windows环境下修改“%TOMCAT_HOME%\bin\catalina.bat”文件,在文件开头增加如下设置:set JAVA_OPTS=-Xms256m - ...
- RavenDb学习(五)结果转换
)Result Transformers public class Order { public DateTime OrderedAt { get; set; } public Status Stat ...
- filter和map的区别
filter和map初一看很像 都是filter(func,iterable) map(func,iterable) 实际情况是filter函数:filter()为已知的序列的每个元素调用给定的布尔函 ...
- Struts 2应用程序安全功能的配置详解
安全性是Web应用程序开发工作中最关键的问题之一.在基于servlet的应用程序里,保护应用程序资源的办法有两种:一是对应用程序进行配置(web.xml),二是使用Java代码硬编码到程序中.前一种方 ...
- Idea maven项目不能新建package和class的解决
如图,新建的maven项目不能新建package 这是因为Java是普通的文件夹,要设置为 现在就可以了
- 【转】Graphics.DrawCurve的算法
public static class Spline { [System.Diagnostics.DebuggerDisplay("({X},{Y})")] public part ...
- Mybatis trim标签
trim代替where/set标签 trim 是更灵活用来去处多余关键字的标签,它可以用来实现 where 和 set 的效果. <!-- 使用 if/trim 代替 where(判断参数) ...
- Maven的生命周期是为了对所有的构建过程进行了抽象了,便于统一。
Maven的生命周期是为了对所有的构建过程进行了抽象了,便于统一. clean(清理) cleanup(清理所有) 此生命周期旨在给工程做清理工作,它主要包含以下阶段: pre-clean - 执行项 ...
- e823. 创建JSplitPane
A split pane divides its space between two components. The split pane contains a divider that allows ...