Yesterday I upgraded XCode and used Apple's translator to change the code from Swift 2 to Swift 3.
Of course there were errors, most of them easy to fix, but there is one that is killing me.
I am making a NSMutableURLRequest. In swift 2, to set the body of the request I did this:
let body = NSMutableData()
//append data
request.httpMethod = "POST"
request.httpBody = body
When I used the translator, all it added was a as Data:
request.httpBody = body as Data
Here it shows the first error:
Cannot convert value of type NSMutableData to type Data in coercion
After trying hours to parse both NSMutableData and NSData to Data and failing (I don't know why it isn't possible) I decided to change the body and the way to append data to type Data. I thought this was going to end the problems, but I was wrong. Now, when I set the httpBody it shows the following error:
Cannot convert value of type Data? to type Data?
I thought this could be a bug but I've restarted my computer and reinstalled XCode and same error.
Is this a bug or am I doing something wrong? Is there an easy way to parse NSMutableData to Data that I didn't find?
Thanks!