Skip to content

Instantly share code, notes, and snippets.



Last active Nov 26, 2018
What would you like to do?
func machineName() -> String {
var systemInfo = utsname()
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