大佬教程收集整理的这篇文章主要介绍了如何获取iphone的硬件版本以及系统信息,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
原文:http://blog.csdn.net/xiaoguan2008/article/details/6582699
@H_801_15@ 获取iphone的系统信息使用[UIDevice currentDevice],信息如下:
[[UIDevice currentDevice] systemName]:系统名称,如iPhone OS
] systemVersion:系统版本,如4.2.1
@H_801_15@ [[currentDevice] @H_66_48@model]:The model of the device,如iPhone或者iPod touch] uniquEIDentifier:设备的惟一标识号,deviceid
@H_801_15@ [[name]:设备的名称,如 张三的iPhone[[UIDevice currentDevice] localizedModel]:The model of the device as a localized String,类似@H_932_6@model
但是以上的信息貌似无法得到设备的硬件信息,例如一个iphone3GS,系统升级到了iphone4。此时使用systemVersion得到的应该是4.x.x,那我们如何知道该设备为iphone3GS呢。网上流传一个方法,经测试应该是有用的。
#import <Foundation/Foundation.h>
@H_801_15@ @interface UIDeviceHardware : NSObject { @H_801_15@ } @H_801_15@ - (NSString *) platform; @H_801_15@ - (NSString *) platformString;@end
#import "UIDeviceHardware.h"
#include <sys/types.h>
#include <sys/sysctl.h>
@H_801_15@ @implementation UIDeviceHardware @H_801_15@ - (NSString *) platform{ @H_801_15@ size_t size; @H_801_15@ sysctlbyname("hw.machine", NULL,&size, 0); @H_801_15@ char *machine = @H_66_48@malloc(sizE); @H_801_15@ 0);NSString *platform = [ StringWithCString:machine encoding:NSUTF8StringEncoding];
@H_801_15@ free(machinE); @H_801_15@ return platform; @H_801_15@ } @H_752_197@@end
使用[[[UIDeviceHardware alloc] init] platform]应该就可以得到设备的硬件版本。
以上是大佬教程为你收集整理的如何获取iphone的硬件版本以及系统信息全部内容,希望文章能够帮你解决如何获取iphone的硬件版本以及系统信息所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。