Post not yet marked as solved
Post marked as unsolved with 2 replies, 288 views
I am running Xcode 10.3 on a MBP from 2015. Does this limit the version of Swift I can write with? How can I tell which version of Swift I am using?
I am getting an error: Value of type URL has no member 'withQueries' and I think it is because the code is incompatible with the version of Swift I am using?
let baseURL = URL(string: "https://api.nasa.gov/planetary/apod")!
let query: [String: String] = [
"api_key": "DEMO_KEY",
"date": "2011-07-13"]
let url = baseURL.withQueries(query)!
let task = URLSession.shared.dataTask(with: url) { (data, response, error) in
if let data = data,
let string = String(data: data, encoding: .utf8) {
print(string)
}
PlaygroundPage.current.finishExecution()
}
task.resume()