I have that code
func SendRequest(request: String) -> String { var response = \"\" var (success, errmsg) = client.connect(timeout: 1) if succe
Answering: "Sometimes, cast NSData to String doesn't work." Not all data is convertible to a particular string encoding. In the case:
var str = String.init(data: bytes, encoding: NSUTF8StringEncoding)
there are a great number of bytes and byte sequences that have no valid UTF-8 character encoding.