国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學(xué)院 > 開發(fā)設(shè)計(jì) > 正文

iOS獲取手機(jī)相關(guān)信息

2019-11-14 19:10:43
字體:
供稿:網(wǎng)友

iOS具體的設(shè)備型號:

#include <sys/types.h>#include <sys/sysctl.h>
- (void)test {    //手機(jī)型號。        size_t size;        sysctlbyname("hw.machine", NULL, &size, NULL, 0);        char *machine = (char*)malloc(size);        sysctlbyname("hw.machine", machine, &size, NULL, 0);        NSString *platform = [NSString stringWithCString:machine encoding:NSUTF8StringEncoding];    NSLog(@"%@",platform);    //這里得到的platform是個(gè)設(shè)備型號。  比如iphone5,2.        //所以如果想更完美點(diǎn),可以自己根據(jù)字符串判斷。        //比如: if ([platform isEqualToString:@"iPhone3,1"])    return @"iPhone 4";    //注:模擬器上運(yùn)行得到的不同}

UIDevice:獲取手機(jī)屬性

- (void)device {        //    [[UIDevice currentDevice] systemName]; // 系統(tǒng)名    //    [[UIDevice currentDevice] systemVersion]; //版本號    //    [[UIDevice currentDevice] model]; //類型,模擬器,真機(jī)    //    [[UIDevice currentDevice] name]; //設(shè)備名稱    //    [[UIDevice currentDevice] localizedModel]; // 本地模式    //設(shè)備相關(guān)信息的獲取    NSString *strName = [[UIDevice currentDevice] name];    NSLog(@"設(shè)備名稱:%@", strName);//e.g. "My iPhone"        NSString *strSysName = [[UIDevice currentDevice] systemName];    NSLog(@"系統(tǒng)名稱:%@", strSysName);// e.g. @"iOS"        NSString *strSysVersion = [[UIDevice currentDevice] systemVersion];    NSLog(@"系統(tǒng)版本號:%@", strSysVersion);// e.g. @"4.0"        NSString *strModel = [[UIDevice currentDevice] model];    NSLog(@"設(shè)備模式:%@", strModel);// e.g. @"iPhone", @"iPod touch"        NSString *strLocModel = [[UIDevice currentDevice] localizedModel];    NSLog(@"本地設(shè)備模式:%@", strLocModel);// localized version of model //地方型號  (國際化區(qū)域名稱)        NSString* phoneModel = [[UIDevice currentDevice] model];    NSLog(@"手機(jī)型號: %@",phoneModel );   //手機(jī)型號}

NSBundle:獲取應(yīng)用名版本號

- (void)bundle {        //app應(yīng)用相關(guān)信息的獲取    NSDictionary *dicInfo = [[NSBundle mainBundle] infoDictionary];    // CFShow(dicInfo);        NSString *strAppName = [dicInfo objectForKey:@"CFBundleDisplayName"];    NSLog(@"App應(yīng)用名稱:%@", strAppName);   // 當(dāng)前應(yīng)用名稱        NSString *strAppVersion = [dicInfo objectForKey:@"CFBundleShortVersionString"];    NSLog(@"App應(yīng)用版本:%@", strAppVersion);    // 當(dāng)前應(yīng)用軟件版本  比如:1.0.1        NSString *strAppBuild = [dicInfo objectForKey:@"CFBundleVersion"];    NSLog(@"App應(yīng)用Build版本:%@", strAppBuild);      // 當(dāng)前應(yīng)用版本號碼   int類型}

 

NSLocale:獲取機(jī)器當(dāng)前語言和國家

-(void)locale {        //Getting the User’s Language    NSArray *languageArray = [NSLocale PReferredLanguages];    NSString *language = [languageArray objectAtIndex:0];    NSLog(@"語言:%@", language);        NSLocale *locale = [NSLocale currentLocale];    NSString *country = [locale localeIdentifier];    NSLog(@"國家:%@", country);}

 

 

發(fā)表評論 共有條評論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 东乌珠穆沁旗| 南涧| 巩留县| 宁国市| 合水县| 汨罗市| 安图县| 灌阳县| 嘉黎县| 库尔勒市| 鄂托克旗| 尤溪县| 九江县| 阿巴嘎旗| 民丰县| 宁蒗| 雷州市| 留坝县| 万年县| 静海县| 江津市| 东丽区| 凤台县| 沾益县| 民勤县| 额尔古纳市| 长沙县| 丹江口市| 桂平市| 建阳市| 沁水县| 马公市| 年辖:市辖区| 台北市| 南川市| 贵德县| 吐鲁番市| 浙江省| 云霄县| 章丘市| 霍林郭勒市|