iPhone应用中如何获取硬件版本以及系统信息
来源:互联网 发布:58群发软件 编辑:程序博客网 时间:2024/05/17 08:25
iPhone应用中如何获取硬件版本以及系统信息
iPhone应用中如何获取硬件版本以及系统信息是本文要介绍的内容,主要是基于代码来实现硬件版本和系统信息的获取,来看详细内容。
AD:51CTO学院:IT精品课程在线看!
iPhone应用中如何获取硬件版本以及系统信息是本文要介绍的内容,主要是基于代码来实现硬件版本和系统信息的获取,来看详细内容。获取iphone的系统信息使用[UIDevice currentDevice],信息如下:
- [[UIDevice currentDevice] systemName]:系统名称,如iPhone OS
- [[UIDevice currentDevice] systemVersion]:系统版本,如4.2.1
- [[UIDevice currentDevice] model]:The model of the device,如iPhone或者iPod touch
- [[UIDevice currentDevice] uniqueIdentifier]:设备的惟一标识号,deviceID
- [[UIDevice currentDevice] name]:设备的名称,如 张三的iPhone
- [[UIDevice currentDevice] localizedModel]:The model of the device as a localized string,类似model
- 详见http://developer.apple.com/library/ios/#documentation/uikit/reference/UIDevice_Class/Reference/UIDevice.html
但是以上的信息貌似无法得到设备的硬件版本以及系统信息,例如一个iphone3GS,系统升级到了iphone 4。此时使用systemVersion得到的应该是4.x.x,那我们如何知道该设备为iphone3GS呢。网上流传一个方法,经测试应该是有用的。
自定义一个类:
- #import <Foundation/Foundation.h>
- @interface UIDeviceHardware : NSObject {
- }
- - (NSString *) platform;
- - (NSString *) platformString;
- @end
- #import "UIDeviceHardware.h"
- #include <sys/types.h>
- #include <sys/sysctl.h>
- @implementation UIDeviceHardware
- - (NSString *) platform{
- size_t size;
- sysctlbyname("hw.machine", NULL, &size, NULL, 0);
- char *machine = malloc(size);
- sysctlbyname("hw.machine", machine, &size, NULL, 0);
- NSString *platform = [NSString stringWithCString:machine encoding:NSUTF8StringEncoding];
- free(machine);
- return platform;
- }
- - (NSString *) platformString{
- NSString *platform = [self platform];
- if ([platform isEqualToString:@"iPhone1,1"]) return @"iPhone 1G";
- if ([platform isEqualToString:@"iPhone1,2"]) return @"iPhone 3G";
- if ([platform isEqualToString:@"iPhone2,1"]) return @"iPhone 3GS";
- if ([platform isEqualToString:@"iPhone3,1"]) return @"iPhone 4";
- if ([platform isEqualToString:@"iPod1,1"]) return @"iPod Touch 1G";
- if ([platform isEqualToString:@"iPod2,1"]) return @"iPod Touch 2G";
- if ([platform isEqualToString:@"iPod3,1"]) return @"iPod Touch 3G";
- if ([platform isEqualToString:@"iPod4,1"]) return @"iPod Touch 4G";
- if ([platform isEqualToString:@"iPad1,1"]) return @"iPad";
- if ([platform isEqualToString:@"i386"] || [platform isEqualToString:@"x86_64"])
- return @"iPhone Simulator";
- return platform;
- }
- @end
使用[[[UIDeviceHardware alloc] init] platform]应该就可以得到设备的硬件版本。源码地址:http://download.csdn.net/source/3415689
小结:iPhone应用中如何获取硬件版本以及系统信息的内容介绍完了,希望通过本文的学习鞥读你有所帮助!
【编辑推荐】
- 详解iPhone开发应用为视图加边框
- iPhone开发关于NSInvocationOperation多线程教程
- 深度解析iPhone窗口和视图
- iPhone开发应用之UIView中动画属性分析
- iPhone开发应用ASIFormDataRequest POST操作架构设计
- iPhone开发应用ASIHTTPRequest如何获取文件流
IOS-获取Model(设备型号)、Version(设备版本号)、app(程序版本号)等
IOS-获取Model(设备型号)、Version(设备版本号)、app(程序版本号)等
NSLog(@"uniqueIdentifier: %@", [[UIDevice currentDevice] uniqueIdentifier]);
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(infoDictionary);
// app名称
NSString *app_Name = [infoDictionary objectForKey:@"CFBundleDisplayName"];
// app版本
NSString *app_Version = [infoDictionary objectForKey:@"CFBundleShortVersionString"];
// app build版本
NSString *app_build = [infoDictionary objectForKey:@"CFBundleVersion"];
IOS-获取Model(设备型号)、Version(设备版本号)、app(程序版本号)等
IOS-获取Model(设备型号)、Version(设备版本号)、app(程序版本号)等
NSLog(@"uniqueIdentifier: %@", [[UIDevice currentDevice] uniqueIdentifier]);
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(infoDictionary);
// app名称
NSString *app_Name = [infoDictionary objectForKey:@"CFBundleDisplayName"];
// app版本
NSString *app_Version = [infoDictionary objectForKey:@"CFBundleShortVersionString"];
// app build版本
NSString *app_build = [infoDictionary objectForKey:@"CFBundleVersion"];
IOS-获取Model(设备型号)、Version(设备版本号)、app(程序版本号)等
IOS-获取Model(设备型号)、Version(设备版本号)、app(程序版本号)等
NSLog(@"uniqueIdentifier: %@", [[UIDevice currentDevice] uniqueIdentifier]);
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(infoDictionary);
// app名称
NSString *app_Name = [infoDictionary objectForKey:@"CFBundleDisplayName"];
// app版本
NSString *app_Version = [infoDictionary objectForKey:@"CFBundleShortVersionString"];
// app build版本
NSString *app_build = [infoDictionary objectForKey:@"CFBundleVersion"];
- iPhone应用中如何获取硬件版本以及系统信息
- iphone 如何获取iphone的硬件版本以及系统信息
- 如何获取iphone的硬件版本以及系统信息
- 如何获取iphone的硬件版本以及系统信息
- 如何获取iphone的硬件版本以及系统信息
- 如何获取iphone的硬件版本以及系统信息
- 如何获取iphone的硬件版本以及系统信息
- 如何获取iphone的硬件版本以及系统信息
- 如何获取iphone的硬件版本以及系统信息
- 获取iphone的硬件版本以及系统信息
- 获取iphone的硬件版本以及系统信息
- Android获取系统的硬件信息、系统版本以及如何检测ROM类型
- .NET中获取系统硬件信息
- .net中如何获取机器硬件信息
- 获取系统硬件信息
- 获取系统硬件信息
- 获取系统硬件信息
- 获取系统硬件信息
- Eclipse中使用Struts2和Tomcat访问Hbase数据库
- 腾讯实习生面试后的一些感悟
- OutLook的临时文件存放位置/打开邮件附件修改并保存附件没有更改
- sed find grep协同作战,实现多文件字符串替换
- kernel: nf_conntrack: table full, dropping packet解决办法
- iPhone应用中如何获取硬件版本以及系统信息
- Creating URL query parameters from NSDictionary objects in ObjectiveC
- PS 图像调整算法——自动对比度 (Auto Contrast)
- [数据结构]一些有意思题目(一)
- linux下配置各种服务器方法汇总
- tomcat中server.xml常用配置
- SGU103+POJ 1158 最短路/dp
- 照相一
- Android Permission