How to convert String to byte in Swift?
Like String .getBytes()
in Java.
There is a more elegant way.
Swift 3:
let str = "Hello"
let buf = [UInt8](str.utf8)
Swift 4: (thanks to @PJ_Finnegan)
let str = "Hello"
let buf: [UInt8] = Array(str.utf8)