IOS 獲得設備類型和系統版本號

在實際開發中,有時需要考慮到兼容性問題,這兩個信息還是很有用的,我一般都是程序開始時讀取,存到公共變量裏。

#import "sys/utsname.h"

 

/*!

 *  get the information of the device and system

 *  "i386"          simulator

 *  "iPod1,1"       iPod Touch

 *  "iPhone1,1"     iPhone

 *  "iPhone1,2"     iPhone 3G

 *  "iPhone2,1"     iPhone 3GS

 *  "iPad1,1"       iPad

 *  "iPhone3,1"     iPhone 4

 *  @return null

 */

- (void)getDeviceAndOSInfo

{

    //here use sys/utsname.h

    struct utsname systemInfo;

    uname(&systemInfo);

    //get the device model and the system version

    NSLog(@"%@", [NSString stringWithCString:systemInfo.machine encoding:NSUTF8StringEncoding]);

    NSLog(@"%@", [[UIDevice currentDevice] systemVersion]);

}


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章