IOS Get Device version model

Source: Internet
Author: User

#import "Sys/utsname.h"

/**
* Device Version
*
* @return e.g. IPhone 5S
*/
+ (nsstring*) deviceversion {
Need #import "Sys/utsname.h"
struct Utsname systemInfo;
Uname (&systeminfo);
NSString *devicestring = [NSString stringWithCString:systemInfo.machine encoding:nsutf8stringencoding];

Iphone
if ([devicestring isequaltostring:@ "iphone1,1"]) return @ "IPhone 1G";
if ([devicestring isequaltostring:@ "iphone1,2"]) return @ "IPhone 3G";
if ([devicestring isequaltostring:@ "iphone2,1"]) return @ "IPhone 3GS";
if ([devicestring isequaltostring:@ "iphone3,1"]) return @ "IPhone 4";
if ([devicestring isequaltostring:@ "iphone3,2"]) return @ "Verizon IPhone 4";
if ([devicestring isequaltostring:@ "iphone4,1"]) return @ "IPhone 4S";
if ([devicestring isequaltostring:@ "iphone5,1"]) return @ "IPhone 5";
if ([devicestring isequaltostring:@ "iphone5,2"]) return @ "IPhone 5";
if ([devicestring isequaltostring:@ "iphone5,3"]) return @ "IPhone 5C";
if ([devicestring isequaltostring:@ "iphone5,4"]) return @ "IPhone 5C";
if ([devicestring isequaltostring:@ "iphone6,1"]) return @ "IPhone 5S";
if ([devicestring isequaltostring:@ "iphone6,2"]) return @ "IPhone 5S";
if ([devicestring isequaltostring:@ "iphone7,1"]) return @ "IPhone 6 Plus";
if ([devicestring isequaltostring:@ "iphone7,2"]) return @ "IPhone 6";
if ([devicestring isequaltostring:@ "iphone8,1"]) return @ "IPhone 6s";
if ([devicestring isequaltostring:@ "iphone8,2"]) return @ "IPhone 6s Plus";
if ([devicestring isequaltostring:@ "iphone8,4"]) return @ "IPhone SE";
if ([devicestring isequaltostring:@ "iphone9,1"]) return @ "IPhone 7";
if ([devicestring isequaltostring:@ "iphone9,3"]) return @ "IPhone 7";
if ([devicestring isequaltostring:@ "iphone9,2"]) return @ "IPhone 7 Plus";
if ([devicestring isequaltostring:@ "iphone9,4"]) return @ "IPhone 7 Plus";

Ipod
if ([devicestring isequaltostring:@ "ipod1,1"]) return @ "IPod Touch 1G";
if ([devicestring isequaltostring:@ "ipod2,1"]) return @ "IPod Touch 2G";
if ([devicestring isequaltostring:@ "ipod3,1"]) return @ "IPod Touch 3G";
if ([devicestring isequaltostring:@ "ipod4,1"]) return @ "IPod Touch 4G";
if ([devicestring isequaltostring:@ "ipod5,1"]) return @ "IPod Touch 5G";
if ([devicestring isequaltostring:@ "ipod7,1"]) return @ "IPod Touch 6G";

Ipad
if ([devicestring isequaltostring:@ "ipad1,1"]) return @ "IPad";
if ([devicestring isequaltostring:@ "ipad2,1"]) return @ "IPad 2 (WiFi)";
if ([devicestring isequaltostring:@ "ipad2,2"]) return @ "IPad 2 (GSM)";
if ([devicestring isequaltostring:@ "ipad2,3"]) return @ "IPad 2 (CDMA)";
if ([devicestring isequaltostring:@ "ipad2,4"]) return @ "IPad 2 (32nm)";
if ([devicestring isequaltostring:@ "ipad2,5"]) return @ "IPad Mini (WiFi)";
if ([devicestring isequaltostring:@ "ipad2,6"]) return @ "IPad Mini (GSM)";
if ([devicestring isequaltostring:@ "ipad2,7"]) return @ "IPad Mini (CDMA)";

if ([devicestring isequaltostring:@ "ipad3,1"]) return @ "IPad 3 (WiFi)";
if ([devicestring isequaltostring:@ "ipad3,2"]) return @ "IPad 3 (CDMA)";
if ([devicestring isequaltostring:@ "ipad3,3"]) return @ "IPad 3 (4G)";
if ([devicestring isequaltostring:@ "ipad3,4"]) return @ "IPad 4 (WiFi)";
if ([devicestring isequaltostring:@ "ipad3,5"]) return @ "IPad 4 (4G)";
if ([devicestring isequaltostring:@ "ipad3,6"]) return @ "IPad 4 (CDMA)";

if ([devicestring isequaltostring:@ "ipad4,1"]) return @ "IPad Air";
if ([devicestring isequaltostring:@ "ipad4,2"]) return @ "IPad Air";
if ([devicestring isequaltostring:@ "ipad4,3"]) return @ "IPad Air";
if ([devicestring isequaltostring:@ "ipad5,3"]) return @ "IPad Air 2";
if ([devicestring isequaltostring:@ "ipad5,4"]) return @ "IPad Air 2";
if ([devicestring isequaltostring:@ "i386"]) return @ "Simulator";
if ([devicestring isequaltostring:@ "x86_64"]) return @ "Simulator";

if ([devicestring isequaltostring:@ "ipad6,7"]) return @ "IPad Pro";
if ([devicestring isequaltostring:@ "ipad6,8"]) return @ "IPad Pro";

if ([devicestring isequaltostring:@ "ipad6,3"]) return @ "IPad Pro";
if ([devicestring isequaltostring:@ "ipad6,4"]) return @ "IPad Pro";

if ([devicestring isequaltostring:@ "ipad4,4"]
|| [Devicestring isequaltostring:@ "ipad4,5"]
||      [Devicestring isequaltostring:@ "ipad4,6"]) return @ "IPad mini 2";

if ([devicestring isequaltostring:@ "ipad4,7"]
|| [Devicestring isequaltostring:@ "ipad4,8"]
||      [Devicestring isequaltostring:@ "ipad4,9"]) return @ "IPad Mini 3";

if ([devicestring isequaltostring:@ "ipad5,1"]
||      [Devicestring isequaltostring:@ "ipad5,2"]) return @ "IPad mini 4";

Apple Watch
if ([devicestring isequaltostring:@ "watch1,1"]) return @ "Apple Watch";
if ([devicestring isequaltostring:@ "watch1,2"]) return @ "Apple Watch";
if ([devicestring isequaltostring:@ "watch2,6"]) return @ "Apple Watch Series 1";
if ([devicestring isequaltostring:@ "watch2,7"]) return @ "Apple Watch Series 1";
if ([devicestring isequaltostring:@ "watch2,3"]) return @ "Apple Watch Series 2";
if ([devicestring isequaltostring:@ "watch2,4"]) return @ "Apple Watch Series 2";

Apple TV
if ([devicestring isequaltostring:@ "appletv2,1"]) return @ "Apple TV 2G";
if ([devicestring isequaltostring:@ "appletv3,1"]) return @ "Apple TV 3G";
if ([devicestring isequaltostring:@ "appletv3,2"]) return @ "Apple TV 3G";
if ([devicestring isequaltostring:@ "appletv5,3"]) return @ "Apple TV 4G";

return devicestring;
}

IOS Get Device version model

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.