Skip to content

Instantly share code, notes, and snippets.

@soapyigu
Last active November 26, 2018 05:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save soapyigu/c99e1f45553070726f14c1bb0a54053b to your computer and use it in GitHub Desktop.
Save soapyigu/c99e1f45553070726f14c1bb0a54053b to your computer and use it in GitHub Desktop.
// https://stackoverflow.com/questions/26028918/how-to-determine-the-current-iphone-device-model
func machineName() -> String {
var systemInfo = utsname()
uname(&systemInfo)
let machineMirror = Mirror(reflecting: systemInfo.machine)
return machineMirror.children.reduce("") { identifier, element in
guard let value = element.value as? Int8, value != 0 else { return identifier }
return identifier + String(UnicodeScalar(UInt8(value)))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment