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"
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"
case "iPhone5,3", "iPhone5,4": return "iPhone 5c"
case "iPhone6,1", "iPhone6,2": return "iPhone 5s"
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", "iPhone9,3": return "iPhone 7"
case "iPhone9,2", "iPhone9,4": return "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獲取手機(jī)型號
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
- 文/潘曉璐 我一進(jìn)店門芳肌,熙熙樓的掌柜王于貴愁眉苦臉地迎上來灵再,“玉大人,你說我怎么就攤上這事亿笤◆崆ǎ” “怎么了?”我有些...
- 文/不壞的土叔 我叫張陵责嚷,是天一觀的道長鸳兽。 經(jīng)常有香客問我,道長罕拂,這世上最難降的妖魔是什么揍异? 我笑而不...
- 正文 為了忘掉前任全陨,我火速辦了婚禮,結(jié)果婚禮上衷掷,老公的妹妹穿的比我還像新娘辱姨。我一直安慰自己,他們只是感情好戚嗅,可當(dāng)我...
- 文/花漫 我一把揭開白布雨涛。 她就那樣靜靜地躺著,像睡著了一般懦胞。 火紅的嫁衣襯著肌膚如雪替久。 梳的紋絲不亂的頭發(fā)上,一...
- 文/蒼蘭香墨 我猛地睜開眼距帅,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了括堤?” 一聲冷哼從身側(cè)響起碌秸,我...
- 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎痊臭,沒想到半個月后哮肚,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
- 正文 獨(dú)居荒郊野嶺守林人離奇死亡广匙,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
- 正文 我和宋清朗相戀三年允趟,在試婚紗的時候發(fā)現(xiàn)自己被綠了。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片鸦致。...
- 正文 年R本政府宣布绽乔,位于F島的核電站弧蝇,受9級特大地震影響,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜看疗,卻給世界環(huán)境...
- 文/蒙蒙 一沙峻、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧两芳,春花似錦摔寨、人聲如沸。這莊子的主人今日做“春日...
- 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至竖螃,卻和暖如春淑廊,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背斑鼻。 一陣腳步聲響...
- 正文 我出身青樓,卻偏偏與公主長得像关摇,于是被迫代替她去往敵國和親荒叶。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當(dāng)晚...