IOS get the latest device model method

Source: Internet
Author: User

1.IOS get the latest device model method
List of the latest tables: Http://theiphonewiki.com/wiki/Models
Method:

#import "sys/utsname.h"struct utsname systemInfo;    uname(&systemInfo);    NSString *deviceString = [NSString stringWithCString:systemInfo.machine encoding:NSUTF8StringEncoding];  

This gets the devicestring is the iphone5,2 device number, according to the table can be obtained to the current phone model.
Full function:

structUtsname SystemInfo; Uname (&systeminfo);NSString*devicestring = [NSStringStringwithcstring:systeminfo. MachineEncoding:nsutf8stringencoding];Nsarray*modelarray = @[@"i386", @"x86_64",                              @"iphone1,1",                              @"iphone1,2",                              @"iphone2,1",                              @"iphone3,1",                              @"iphone3,2",                              @"iphone3,3",                              @"iphone4,1",                              @"iphone5,1",                              @"iphone5,2",                              @"iphone5,3",                              @"iphone5,4",                              @"iphone6,1",                              @"iphone6,2",                              @"ipod1,1",                              @"ipod2,1",                              @"ipod3,1",                              @"ipod4,1",                              @"ipod5,1",                              @"ipad1,1",                              @"ipad2,1",                              @"ipad2,2",                              @"ipad2,3",                              @"ipad2,4",                              @"ipad3,1",                              @"ipad3,2",                              @"ipad3,3",                              @"ipad3,4",                              @"ipad3,5",                              @"ipad3,6",                              @"ipad2,5",                              @"ipad2,6",                              @"ipad2,7",                              ];Nsarray*modelnamearray = @[@"IPhone Simulator", @"IPhone Simulator",                                  @"IPhone 2G",                                  @"IPhone 3G",                                  @"IPhone 3GS",                                  @"IPhone 4 (GSM)",                                  @"IPhone 4 (GSM Rev A)",                                  @"IPhone 4 (CDMA)",                                  @"IPhone 4S",                                  @"IPhone 5 (GSM)",                                  @"IPhone 5 (GSM+CDMA)",                                  @"IPhone 5c (GSM)",                                  @"IPhone 5c (Global)",                                  @"iphone 5s (GSM)",                                  @"iphone 5s (Global)",                                  @"IPod Touch 1G",                                  @"IPod Touch 2G",                                  @"IPod Touch 3G",                                  @"IPod Touch 4G",                                  @"IPod Touch 5G",                                  @"IPad",                                  @"IPad 2 (WiFi)",                                  @"IPad 2 (GSM)",                                  @"IPad 2 (CDMA)",                                  @"IPad 2 (WiFi + New Chip)",                                  @"IPad 3 (WiFi)",                                  @"IPad 3 (GSM+CDMA)",                                  @"IPad 3 (GSM)",                                  @"IPad 4 (WiFi)",                                  @"IPad 4 (GSM)",                                  @"IPad 4 (GSM+CDMA)",                                  @"IPad Mini (WiFi)",                                  @"IPad Mini (GSM)",                                  @"ipad Mini (GSM+CDMA)"];NsintegerModelindex =-1;NSString*modelnamestring =Nil; Modelindex = [Modelarray indexofobject:devicestring];if(Modelindex >=0&& Modelindex < [Modelnamearray count]) {modelnamestring = [Modelnamearray objectatindex:modelindex]; }NSLog(@"----Device type---%@", modelnamestring);

Note: struct utsname systemInfo; This is where the Linux system puts the hardware version information.

Appendix:

?//ios-Get Model (device model), version (device version number), app (program version number), etc.    NSLog(@"Name:%@", [[Uidevice Currentdevice] name];NSLog(@"SystemName:%@", [[Uidevice Currentdevice] systemName]);NSLog(@"systemversion:%@", [[Uidevice Currentdevice] systemversion]);NSLog(@"model:%@", [[Uidevice Currentdevice] model]);NSLog(@"Localizedmodel:%@", [[Uidevice Currentdevice] localizedmodel]);nsdictionary*infodictionary = [[NSBundleMainbundle] infodictionary]; Cfshow ((__bridge cftyperef) (infodictionary));//App name    NSString*app_name = [Infodictionary objectforkey:@"Cfbundledisplayname"];//App version    NSString*app_version = [Infodictionary objectforkey:@"Cfbundleshortversionstring"];//App build version    NSString*app_build = [Infodictionary objectforkey:@"Cfbundleversion"]; 

IOS get the latest device model method

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.