Last active
January 31, 2018 20:36
-
-
Save brokaw/8af52323b6b213ecd2f33f1324192f3f to your computer and use it in GitHub Desktop.
Alternative to using baseAddress!.assumingMemoryBound
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Darwin | |
var utsInfo = utsname() | |
uname(&utsInfo) | |
let machine = withUnsafeBytes(of: &utsInfo.machine) { (ptr) -> String? in | |
return Data(ptr).withUnsafeBytes({ (ptr: UnsafePointer<CChar>) -> String? in | |
return String(cString: ptr) | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment