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);}
新聞熱點(diǎn)
疑難解答
圖片精選