-
-
Save laevandus/a046cec8d222c95a4e1db1912f59649e to your computer and use it in GitHub Desktop.
This file contains 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
var input = UInt16(1024) | |
// UInt16 -› Data | |
let data = Data(bytes: &input, count: MemoryLayout<UInt16>.size) | |
// Data -> UInt16 | |
let output = data.withUnsafeBytes({ $0.load(as: UInt16.self) }) | |
print(output) // 1024 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment