偷偷摘套内射激情视频,久久精品99国产国产精,中文字幕无线乱码人妻,中文在线中文a,性爽19p

iPhone應(yīng)用中如何獲取硬件版本以及系統(tǒng)信息

移動(dòng)開發(fā) iOS
iPhone應(yīng)用中如何獲取硬件版本以及系統(tǒng)信息是本文要介紹的內(nèi)容,主要是基于代碼來實(shí)現(xiàn)硬件版本和系統(tǒng)信息的獲取,來看詳細(xì)內(nèi)容。

iPhone應(yīng)用中如何獲取硬件版本以及系統(tǒng)信息是本文要介紹的內(nèi)容,主要是基于代碼來實(shí)現(xiàn)硬件版本系統(tǒng)信息的獲取,來看詳細(xì)內(nèi)容。獲取iphone的系統(tǒng)信息使用[UIDevice currentDevice],信息如下:

 

  1. [[UIDevice currentDevice] systemName]:系統(tǒng)名稱,如iPhone OS  
  2.  
  3. [[UIDevice currentDevice] systemVersion]:系統(tǒng)版本,如4.2.1  
  4.  
  5. [[UIDevice currentDevice] model]:The model of the device,如iPhone或者iPod touch  
  6.  
  7. [[UIDevice currentDevice] uniqueIdentifier]:設(shè)備的惟一標(biāo)識(shí)號(hào),deviceID  
  8.  
  9. [[UIDevice currentDevice] name]:設(shè)備的名稱,如 張三的iPhone  
  10.  
  11. [[UIDevice currentDevice] localizedModel]:The model of the device as a localized string,類似model 
  1. 詳見http://developer.apple.com/library/ios/#documentation/uikit/reference/UIDevice_Class/Reference/UIDevice.html 

但是以上的信息貌似無法得到設(shè)備的硬件版本以及系統(tǒng)信息,例如一個(gè)iphone3GS,系統(tǒng)升級(jí)到了iphone 4。此時(shí)使用systemVersion得到的應(yīng)該是4.x.x,那我們?nèi)绾沃涝撛O(shè)備為iphone3GS呢。網(wǎng)上流傳一個(gè)方法,經(jīng)測(cè)試應(yīng)該是有用的。

自定義一個(gè)類:

  1. #import <Foundation/Foundation.h> 
  2. @interface UIDeviceHardware : NSObject {     
  3. }  
  4. - (NSString *) platform;  
  5. - (NSString *) platformString;  
  6. @end  
  7. #import "UIDeviceHardware.h"  
  8. #include <sys/types.h> 
  9. #include <sys/sysctl.h> 
  10. @implementation UIDeviceHardware  
  11. - (NSString *) platform{  
  12.     size_t size;  
  13.     sysctlbyname("hw.machine", NULL, &size, NULL, 0);  
  14.     char *machine = malloc(size);  
  15.     sysctlbyname("hw.machine", machine, &size, NULL, 0);  
  16.     NSString *platform = [NSString stringWithCString:machine encoding:NSUTF8StringEncoding];  
  17.     free(machine);  
  18.     return platform;  
  19. }  
  20.  
  21. - (NSString *) platformString{  
  22.     NSString *platform = [self platform];  
  23.     if ([platform isEqualToString:@"iPhone1,1"])    return @"iPhone 1G";  
  24.     if ([platform isEqualToString:@"iPhone1,2"])    return @"iPhone 3G";  
  25.     if ([platform isEqualToString:@"iPhone2,1"])    return @"iPhone 3GS";  
  26.     if ([platform isEqualToString:@"iPhone3,1"])    return @"iPhone 4";  
  27.     if ([platform isEqualToString:@"iPod1,1"])      return @"iPod Touch 1G";  
  28.     if ([platform isEqualToString:@"iPod2,1"])      return @"iPod Touch 2G";  
  29.     if ([platform isEqualToString:@"iPod3,1"])      return @"iPod Touch 3G";  
  30.     if ([platform isEqualToString:@"iPod4,1"])      return @"iPod Touch 4G";  
  31.     if ([platform isEqualToString:@"iPad1,1"])      return @"iPad";  
  32.     if ([platform isEqualToString:@"i386"] || [platform isEqualToString:@"x86_64"])        
  33.   return @"iPhone Simulator";  
  34.     return platform;  
  35. }  
  36. @end 

使用[[[UIDeviceHardware alloc] init] platform]應(yīng)該就可以得到設(shè)備的硬件版本。源碼地址:http://download.csdn.net/source/3415689

小結(jié):iPhone應(yīng)用中如何獲取硬件版本以及系統(tǒng)信息的內(nèi)容介紹完了,希望通過本文的學(xué)習(xí)鞥讀你有所幫助!

責(zé)任編輯:zhaolei 來源: 互聯(lián)網(wǎng)
相關(guān)推薦

2018-07-30 08:56:03

LinuxUbuntu版本

2018-07-27 15:50:55

LinuxUbuntu版本

2011-08-19 14:34:03

iPhone開發(fā)

2015-05-25 19:37:17

InxiLinux

2015-12-21 13:34:31

LinuxGPU顯卡硬件

2011-08-12 13:35:23

iPhone文件流ASIHTTPRequ

2022-11-06 19:34:53

UbuntuLinux

2010-11-05 13:02:58

內(nèi)存iPhone

2012-04-26 13:17:56

iPhone應(yīng)用發(fā)布登錄銀行信息

2011-08-17 15:10:21

iPhone開發(fā)Web視圖

2009-09-25 10:48:07

Linux硬件信息操作系統(tǒng)

2013-03-27 10:32:22

2011-07-28 14:00:45

Ubuntu

2011-08-02 17:27:06

iPhone應(yīng)用 剪切技巧

2019-05-24 14:15:30

Linux硬件信息命令

2011-08-10 17:37:00

iPhoneASIHTTPRequ

2011-08-02 17:14:41

iPhone應(yīng)用 UITableVie

2018-01-08 15:50:21

Linux命令系統(tǒng)和硬件

2013-01-14 16:00:29

Linux系統(tǒng)

2010-07-30 14:28:24

RIP協(xié)議
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)