Swift gets iphone device model

Source: Internet
Author: User

MARK:-uidevice extension

Public extension Uidevice {

var modelname:string {

var systemInfo = Utsname ()

Uname (&systeminfo)

Let Machinemirror = Mirror (reflecting:systemInfo.machine)

Let identifier = MachineMirror.children.reduce ("") {identifier, element in

Guard Let value = Element.value as? Int8, Value! = 0 else {return identifier}

Return identifier + String (Unicodescalar (UInt8 (value)))

}

Switch identifier {

Case "ipod1,1": Return "IPod Touch 1"

Case "ipod2,1": Return "IPod Touch 2"

Case "ipod3,1": Return "IPod Touch 3"

Case "ipod4,1": Return "IPod Touch 4"

Case "ipod5,1": Return "IPod Touch (5 Gen)"

Case "ipod7,1": Return "IPod Touch 6"

Case "iphone3,1", "iphone3,2", "iphone3,3": Return "IPhone 4"

Case "iphone4,1": Return "IPhone 4s"

Case "iphone5,1": Return "IPhone 5"

Case "iphone5,2": Return "IPhone 5 (GSM+CDMA)"

Case "iphone5,3": Return "IPhone 5c (GSM)"

Case "iphone5,4": Return "IPhone 5c (GSM+CDMA)"

Case "iphone6,1": Return "IPhone 5s (GSM)"

Case "iphone6,2": Return "IPhone 5s (GSM+CDMA)"

Case "iphone7,2": Return "IPhone 6"

Case "iphone7,1": Return "IPhone 6 Plus"

Case "iphone8,1": Return "IPhone 6s"

Case "iphone8,2": Return "IPhone 6s Plus"

Case "iphone8,4": Return "IPhone SE"

Case "iphone9,1": Return "national line, Japanese version, Hong Kong iphone 7"

Case "iphone9,2": Return "Hong Kong, National line iphone 7 Plus"

Case "iphone9,3": Return "US version, Taiwan version of iphone 7"

Case "iphone9,4": Return "US version, Taiwan version iphone 7 Plus"

Case "iphone10,1", "iphone10,4": Return "IPhone 8"

Case "iphone10,2", "iphone10,5": Return "IPhone 8 Plus"

Case "iphone10,3", "iphone10,6": Return "IPhone X"

Case "ipad1,1": Return "IPad"

Case "ipad1,2": Return "IPad 3G"

Case "ipad2,1", "ipad2,2", "ipad2,3", "ipad2,4": Return "IPad 2"

Case "ipad2,5", "ipad2,6", "ipad2,7": Return "IPad Mini"

Case "ipad3,1", "ipad3,2", "ipad3,3": Return "IPad 3"

Case "ipad3,4", "ipad3,5", "ipad3,6": Return "IPad 4"

Case "ipad4,1", "ipad4,2", "ipad4,3": Return "IPad Air"

Case "ipad4,4", "ipad4,5", "ipad4,6": Return "IPad Mini 2"

Case "ipad4,7", "ipad4,8", "ipad4,9": Return "IPad Mini 3"

Case "ipad5,1", "ipad5,2": Return "IPad Mini 4"

Case "ipad5,3", "ipad5,4": Return "IPad Air 2"

Case "ipad6,3", "ipad6,4": Return "IPad Pro 9.7"

Case "ipad6,7", "ipad6,8": Return "IPad Pro 12.9"

Case "appletv2,1": Return "Apple TV 2"

Case "appletv3,1", "appletv3,2": Return "Apple TV 3"

Case "appletv5,3": Return "Apple TV 4"

Case "i386", "x86_64": Return "Simulator"

Default:return identifier

}

}

}

Swift gets iphone device model

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.