如何获取iphone的硬件版本以及系统信息

如何获取iphone的硬件版本以及系统信息,第1张

概述原文:http://blog.csdn.net/xiaoguan2008/article/details/6582699 获取iphone的系统信息使用[UIDevice currentDevice],信息如下: [[UIDevice currentDevice] systemName]:系统名称,如iPhone OS [[UIDevice currentDevice] systemVersion

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


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

[[UIDevice currentDevicesystemname]:系统名称,如iPhone OS

] systemVersion:系统版本,如4.2.1

[[currentDevicemodel]The model of the device,如iPhone或者iPod touch

] uniqueIDentifIEr:设备的惟一标识号,deviceid

[[name]:设备的名称,如 张三的iPhone

[[UIDevice currentDevicelocalizedModel]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,系统升级到了iphone4。此时使用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>

@H_403_149@@implementation UIDeviceHarDWare

- (Nsstring *) platform{

    size_t size;

    sysctlbyname("hw.machine", @H_403_149@NulL,&size, 0);

    @H_403_149@char *machine = malloc(size);

    0);

    Nsstring *platform = [ stringWithCString:machine enCoding:NSUTF8StringEnCoding];

    free(machine);

    @H_403_149@return platform;

}


- (Nsstring *) platformString{

    Nsstring *platform = [@H_403_149@self platform];

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

    ])    @"iPhone 3G";

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

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

    @"iPod1,1"])      @"iPod touch 1G";

    @"iPod2,31)">@"iPod touch 2G";

    @"iPod3,31)">@"iPod touch 3G";

    @"iPod4,31)">@"iPod touch 4G";

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

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

    @H_403_149@return platform;

}

@end


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

总结

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

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

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1091058.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-27
下一篇 2022-05-27

发表评论

登录后才能评论

评论列表(0条)

保存