I am using the SwiftSocket library and I am trying to convert the data the UDP socket receives from type 'UInt8?, String, Int' to type String.
let data = client.recv(1024)
let string = NSData.withBytes(data)
let str = NSString(data: string, encoding: NSUTF8StringEncoding) as String?
When I attempt this I get the following error:
Cannot convert value of type '((UInt8]?,String,Int)' (aka'(Optional>, String, Int)') to be expected argument type '[UInt8'
If I print out 'data', i receive the following:
(Optional([104, 101, 108, 108, 111]), "127.0.0.1", 34835)
Where 104,101,108,108,111 is the string "hello".
Is there way to convert the data read to string?