var quotes: [(quote: String, order: Int)];
let url = URL(string:"https://www.TEST.com/test_connection.php"){
URLSession.shared.dataTask(with: url) { (data, response, error) in
if let data = data{
if let json = try? JSONDecoder().decode([[String:String]].self, from: data){
json.forEach { row in
quotes.append((row["quote"]!, Int(row["order"]!)!))
}}}}}
Thank you very much @Claude31. If I put "print(output)" before the "return output" line I am getting this in the debug area (1 each on separate lines):
[]
[]
[]
I don't know why there are only 3 brackets or why they are empty, the webservice has about 1000 dictionaries
Apologies @darkpaw I forgot to update the struct for the test project but I still get the error. I will repost the question to avoid confusion to others.
Thank you @endecotp , sorry please could you explain why does creating the instance of API not work as a global, whereas it does work in the tableview controller? I tested the latter and it did work, thank you :-)
var quotes: [(quote: String, order: Int)];
let url = URL(string:"https://www.TEST.com/test_connection.php"){
URLSession.shared.dataTask(with: url) { (data, response, error) in
if let data = data{
if let json = try? JSONDecoder().decode([[String:String]].self, from: data){
json.forEach { row in
quotes.append((row["quote"]!, Int(row["order"]!)!))
}}}}}
Thank you very much @Claude31. If I put "print(output)" before the "return output" line I am getting this in the debug area (1 each on separate lines):
[]
[]
[]
I don't know why there are only 3 brackets or why they are empty, the webservice has about 1000 dictionaries
Apologies @darkpaw I forgot to update the struct for the test project but I still get the error. I will repost the question to avoid confusion to others.
Thank you @endecotp , sorry please could you explain why does creating the instance of API not work as a global, whereas it does work in the tableview controller? I tested the latter and it did work, thank you :-)