Post

Replies

Boosts

Views

Activity

How to convert a function into a variable?
Hello, I have a test variable here which works fine: var quotes: [(quote: String, order: Int)] = [ ("I live you the more ...", 1), ("There is nothing permanent ...", 2), ("You cannot shake hands ...", 3), ("Lord, make me an instrument...", 4) ] and I have a test function which successfully pulls data from a mysql database via a web service and displays it via the "print" function: func getPrice(){ if 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 print(row["quote"]!) print(row["order"]!) } } else{ } } else{ print("wrong :-(") } }.resume() } } Please can you tell me how to re-write the quotes variable/array so that it returns the results that are found in the getPrice() function?
1
0
65
9h
cell.textLabel?.text breaking if a number value is in an array
Hi the below array and code to output a list item works fine: var quotes = [ [ "quote": "I live you the more ...", "order": "1" ], [ "quote": "There is nothing permanent ...", "order": "2" ], [ "quote": "You cannot shake hands ...", "order": "3" ], [ "quote": "Lord, make me an instrument...", "order": "4" ] ] cell.textLabel?.text = quotes[indexPath.row]["quote"] However if I change the "order" values to be numbers rather than text like below then for the above line I get an error message in Xcode "No exact matches in call to subscript". Please could someone tell me how to make it work with the numbers stored as numbers? (I'm wondering if creating an any array type and using the .text function has caused a conflict but I can't find how to resolve) [ "quote": "I live you the more ...", "order": 1 ], [ "quote": "There is nothing permanent ...", "order": 2 ], [ "quote": "You cannot shake hands ...", "order": 3 ], [ "quote": "Lord, make me an instrument...", "order": 4 ] ] Thank you for any pointers :-)
2
0
210
2w
How to get iOS 16 Hello World code showing in Xcode 16
Hello, I have installed the latest Xcode (v 16.2). I would like to code for minimum iOS installation v 16. The default Hello World code in Xcode 16.2 has error messages because some of the code requires minimum target installation of iOS v 17. Please can you tell me how to get the default Hello World code for minimum target iOS 16 to show in Xcode 16? (I considered installing Xcode 14, but the minimum Xcode for deployment is v15) Thank you for any help
2
0
177
Jan ’25