user481610 user481610 - 1 year ago 105
Swift Question

How to print the content of a variable type Data using swift?

All I am looking to is take a string and get its hex value. I've been following this post, here is the code I have in the playground:

let str = "Say Hello to My Little Friend"
let data =

However, I just printed out this:

"60 bytes\n"

. How do I get the hex value of:


Answer Source


print("\(data! as NSData)")

PS: Your expected hex is .utf8

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download