Hi,
I'm fairly new to swift 3 but have done a couple practice apps where I'm going to web pages and pulling data. I started to make a new app but this time when I get the data back it is blank. If I look at the the task response [print(response)] I get the following:
Optional(<NSHTTPURLResponse: 0x61000002e6a0> { URL: https url goes here } { status code: 404, headers {"Strict-Transport-Security" = "max-age=86400";
} })
It seems there is an issue with the security of it being a HTTPS. I have the info.plist settings as:
App Transport Security Settings
Execption Domains
detroit.craigslist.org
NSIncludesSubdomains [Boolean - YES]
NSTemporaryExceptionAllowsInsecureHTTPSLoads [Boolean - YES]
Allow Arbitrary Loads [Boolean - NO]
My question is what can I do to resolve this error so I may pull data from the server? Thanks.
Here is my code:
let group = DispatchGroup()
group.enter()
if let url = URL(string: https url goes here)
let request = NSMutableURLRequest(url: url)
let task = URLSession.shared.dataTask(with: request as URLRequest) {
data, response, error in
if error != nil {
print("error")
} else {
if let unwrappedData = data {
let dataString = NSString(data: unwrappedData, encoding: String.Encoding.utf8.rawValue)
print(dataString)
}
}
group.leave()
}
task.resume()
}