iOS具体的设备型号:
#include <sys/types.h>#include <sys/sysctl.h>
- (void)test { //手机型号。 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是个设备型号。 比如iphone5,2. //所以如果想更完美点,可以自己根据字符串判断。 //比如: if ([platform isEqualToString:@"iPhone3,1"]) return @"iPhone 4"; //注:模拟器上运行得到的不同}
UIDevice:获取手机属性
- (void)device { // [[UIDevice currentDevice] systemName]; // 系统名 // [[UIDevice currentDevice] systemVersion]; //版本号 // [[UIDevice currentDevice] model]; //类型,模拟器,真机 // [[UIDevice currentDevice] name]; //设备名称 // [[UIDevice currentDevice] localizedModel]; // 本地模式 //设备相关信息的获取 NSString *strName = [[UIDevice currentDevice] name]; NSLog(@"设备名称:%@", strName);//e.g. "My iPhone" NSString *strSysName = [[UIDevice currentDevice] systemName]; NSLog(@"系统名称:%@", strSysName);// e.g. @"iOS" NSString *strSysVersion = [[UIDevice currentDevice] systemVersion]; NSLog(@"系统版本号:%@", strSysVersion);// e.g. @"4.0" NSString *strModel = [[UIDevice currentDevice] model]; NSLog(@"设备模式:%@", strModel);// e.g. @"iPhone", @"iPod touch" NSString *strLocModel = [[UIDevice currentDevice] localizedModel]; NSLog(@"本地设备模式:%@", strLocModel);// localized version of model //地方型号 (国际化区域名称) NSString* phoneModel = [[UIDevice currentDevice] model]; NSLog(@"手机型号: %@",phoneModel ); //手机型号}
NSBundle:获取应用名版本号
- (void)bundle { //app应用相关信息的获取 NSDictionary *dicInfo = [[NSBundle mainBundle] infoDictionary]; // CFShow(dicInfo); NSString *strAppName = [dicInfo objectForKey:@"CFBundleDisplayName"]; NSLog(@"App应用名称:%@", strAppName); // 当前应用名称 NSString *strAppVersion = [dicInfo objectForKey:@"CFBundleShortVersionString"]; NSLog(@"App应用版本:%@", strAppVersion); // 当前应用软件版本 比如:1.0.1 NSString *strAppBuild = [dicInfo objectForKey:@"CFBundleVersion"]; NSLog(@"App应用Build版本:%@", strAppBuild); // 当前应用版本号码 int类型}
images/loading.gif' data-original="data:<;base64,iVBORw0KGgoAAAANSUhEUgAAAawAAAAnCAYAAABTyHwDAAAL8mlDQ1BJQ0MgUHJvZmlsZQAASImVVwdUk0nXnrekAQklgICU0DuG3qSE3kE62AhJIIEQYgIo2JXFFVwLIqKorOgi2NcCyFoRxcKq2LAviCgo62IBCyrfJKDuf87v+c53c27meZ/33jt37jszZwYAWjJbLBaiKgDkiPIkscF+jOSUVAbpL4ADRYABB2DF5kjFrJiYCPBDGbkNEFl7w1YW68d2/6+ocnlSDgBIDMTpXCknB+IjAGDeHLEkDwD8LeSN5+aJISZoQawugQlCbCPDmePYV4bTx3G83CY+1h9iPgBkJTZbkgkAFfoDRgEnE7bUCoiZIq5ABHEbxN4cPpsLAA2H2CYnJ1eGmRBbpP8rTub/iZn+LSabnfkNj49FLuQAgVQsZBf+j+X475IjzP/ahxFUJb4kJFbWwrrVZ+eGyzBRVkNRelT0BN8i4MrtFSA+z88PSYAY1hK5xpH6w5oBGsT9XHZA+ITNSH52AmucRwFbIvdVh5gmyAuN/2ovyY2diI8a8aSBcRDDWYTa8XmhEeM5oN4iYZQMW0AckCEICp2wFxbx45MmbOYVCBKjJnwXSbPjwif6XV3E94+asNkiyY9NmOBrMyRBsjHC74MezJHKc5Px3Rz29xzy+PEhE/glT5oc8ZXn8gICv+bPEyXETfh+Eef5xX7lxUL5XB+3EQbHjtcEU5IW
NSLocale:获取机器当前语言和国家
-(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);}
原标题:iOS获取手机相关信息
关键词:IOS