HTML5   发布时间:2022-04-27  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了如何获取iphone的硬件版本以及系统信息大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

原文:http://blog.csdn.net/xiaoguan2008/article/details/6582699


@H_801_15@ 获取iphone的系统信息使用[UIDevice currentDevice],信息如下:

[[UIDevice currentDevicesystemName]:系统名称,如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 currentDevicelocalizedModel]The model of the device as a localized String,类似@H_932_6@model

详见http://developer.apple.com/library/ios/#documentation/uikit/reference/UIDevice_Class/Reference/UIDevice.html


但是以上的信息貌似无法得到设备的硬件信息,例如一个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@

@H_801_15@ - (NSString *) platformString{

@H_801_15@     NSString *platform = [self platform];

@H_801_15@     if ([platform isEqualToString:@"iPhone1,1"])    return @"iPhone 1G";

@H_801_15@     ])    @"iPhone 3G";

@H_801_15@     @"iPhone2,31)">@"iPhone 3GS";

@H_801_15@     @"iPhone3,31)">@"iPhone 4";

@H_801_15@     @"iPod1,1"])      @"iPod Touch 1G";

@H_801_15@     @"iPod2,31)">@"iPod Touch 2G";

@H_801_15@     @"iPod3,31)">@"iPod Touch 3G";

@H_801_15@     @"iPod4,31)">@"iPod Touch 4G";

@H_801_15@     @"iPad1,31)">@"iPad";

@H_801_15@     @"i386"] || [platform @"x86_64"])         return@"iPhone Simulator";

@H_801_15@     return platform;

@H_801_15@ }

@end


使用[[[UIDeviceHardware alloc] init] platform]应该就可以得到设备的硬件版本。

大佬总结

以上是大佬教程为你收集整理的如何获取iphone的硬件版本以及系统信息全部内容,希望文章能够帮你解决如何获取iphone的硬件版本以及系统信息所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。