Skip to content

Instantly share code, notes, and snippets.

@soapyigu

soapyigu/MachineName.swift

Last active Nov 26, 2018
Embed
What would you like to do?
// 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