iOS 获取设备型号,新增2020年新款iPad

class func getDeviceInfo() -> (model: String) {
        if let bundlePath = Bundle.main.path(forResource: "DeviceInfo", ofType: "plist") {
            let dicData = NSDictionary(contentsOfFile: bundlePath) as! Dictionary
            var systemInfo = utsname()
            uname(&systemInfo)
            let platform = withUnsafePointer(to: &systemInfo.machine.0) { ptr in
                return String(cString: ptr)
            }
            guard let plat = dicData[platform] else {
                return ("iPhone")
            }
            return (plat as! String)
        }
        return ("iPhone")
    }

DeviceInfo.plist文件可见链接

你可能感兴趣的:(iOS 获取设备型号,新增2020年新款iPad)