Reference: stackoverflow fix found here
The correct url i was suppose to be using was https://api.stackexchange.com/2.2/search?order=desc&sort=activity&intitle=swift&site=stackoverflow
First of all, you're using the documentation URL as endpoint, instead of the API endpoint, so you get HTML back, not JSON.
You can find the correct URL on that page, it's just below the parameters (hover over it to see the complete URL including the domain name):
Also, this line
request.addValue("intitle", forHTTPHeaderField: text)
is wrong; you can't ...