Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. let string = "message"
  2. let array = Array(string.utf8)
  3. let bytes = Data(string.utf8)
  4.  
  5. CALL_C_FUNC(string, Int32(string.count)) //works
  6. CALL_C_FUNC(array, Int32(array.count)) //works
  7. CALL_C_FUNC(bytes, Int32(bytes.count)) //does not work
  8.  
  9. //instead use:
  10. bytes.withUnsafeBytes { (pBytes: UnsafePointer<UInt8>) in
  11. CALL_C_FUNC(pBytes, Int32(bytes.count))
  12. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement