When I using NSOutputStream\'s write method
NSOutputStream
write
func write(_ buffer: UnsafePointer, maxLength length: Int) -> Int
By far the easiest way (in Swift 5):
let s = "hello, world" let pointer = UnsafePointer(Array(s.utf8CString))
Not sure how backwards compatible this is.