Post

Replies

Boosts

Views

Activity

Comment on How to convert a function into a variable?
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"]!)!)) }}}}}
Feb ’25
Comment on Class not being called?
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 :-)
Replies
Boosts
Views
Activity
Mar ’25
Comment on Not understanding synchronous/asynchronous code
Thank you @endecotp :-)
Replies
Boosts
Views
Activity
Mar ’25
Comment on json array shows in debugger but can't parse
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.
Replies
Boosts
Views
Activity
Mar ’25
Comment on json array shows in debugger but can't parse
Are you saying you think there may be an error in the json file? I don't understand.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Mar ’25
Comment on How to integrate data from a web service into an array
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
Replies
Boosts
Views
Activity
Mar ’25
Comment on How to create an array using a loop
Thank you Claude :-)
Replies
Boosts
Views
Activity
Mar ’25
Comment on How to convert a function into a variable?
Thank you Quinn, the users will be happy to wait until the data is retrieved - a spinning wheel would be fine.
Replies
Boosts
Views
Activity
Mar ’25
Comment on How to convert a function into a variable?
I tried the above but I'm getting an error "type "_" cannot be used as a boolean" for the "let url" line
Replies
Boosts
Views
Activity
Feb ’25
Comment on How to convert a function into a variable?
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"]!)!)) }}}}}
Replies
Boosts
Views
Activity
Feb ’25
Comment on How to convert a function into a variable?
OK sorry I don't think I understand, isn't "return" used for functions but "quotes" is a variable?
Replies
Boosts
Views
Activity
Feb ’25
Comment on cell.textLabel?.text breaking if a number value is in an array
Thank you @darkpaw ! I'll go with the simple solution! :-)
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Feb ’25