In this quick Swift tutorial, I wanted to share how to convert a Data object into String. This is very helpful when you want to print out in Xcode console the response string returned in the body of the HTTP response. This is of course if you know the HTTP response body contains a JSON/text/XML rather than an image for example.
Convert Data object to String
let stringValue = String(decoding: data, as: UTF8.self) print(stringValue)
I hope this little Swift code snippet will be of some value to you!