Post

Replies

Boosts

Views

Activity

SwiftUI not in Apple's App Development Books?
Apple's online "Books" for App Development have been updated, and yet the most recent Develop In Swift Fundamentals from July, 2020 seems to be using UIKit and Storyboard rather than SwiftUI. Have I missed something? Is there another Apple Book to teach young programmers that includes SwiftUI? Thanks, Mike
0
0
189
Nov ’20
Unable to Parse API for Exchange Rate
We are new programmers and are trying to parse an Exchange Rate API. We are able to pull data from the API, but are unable to extract and use that data.Line 54 shows the API is working, and will show the correct data in the debug area.Line 58 is, we believe, the problem area.Any suggestions are appreciated.Kind Regards,import UIKit struct ExchangeRates: Decodable { var base: String = "" var rates: [String: Double] } class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view. getExRate(currencyBase: "USD") //this whole for-in loop did not work for (key, value) in updatedExRates { // var exchangeRateValue: Double if (key == "HUF"){ // exchangeRateValue = value print(value) displayLabel.text! = "\(key): \(value)" } } } @IBOutlet weak var displayLabel: UILabel! var updatedExRates = [String: Double]() func getExRate(currencyBase: String) { // ((completion: @escaping(Result<exchangerates, currencyerror="">) -> Void)) let resourceString = "https://api.exchangeratesapi.io/latest?base=\(currencyBase)" let resourceURL = URL(string: resourceString) print(resourceURL!) guard resourceURL != nil else{ return } let session = URLSession.shared let dataTask = session.dataTask(with: resourceURL!) { (data, response, error) in //check for error if error == nil && data != nil { //parse JSON let decoder = JSONDecoder() do{ let exRates = try decoder.decode(ExchangeRates.self, from: data!) print(exRates) //this works(see debug area) // this is where the issue started to occur. //It does not assign the dictionary to this variable I have created(returns nil instead). self.updatedExRates = exRates.rates } catch { print("error in JSON parsing") } } } //Make the API call dataTask.resume() } }
4
0
1.1k
Apr ’20
Error in Lesson 16 QuestionBot 2
Apple developed Project files from Intro to App Development Lesson 16 on QuestionBot 2 are giving me errors as follows:The project will build and run fine. It will also answer the first question. However, asking a 2nd question causes an error of "Thread 1: signal SIGABRT". This is a file straight from the Apple Tutorial. Suggestions?Project files give warnings for depricated code are given as follows: "The use of Swift 3 @objc inference in Swift 4 mode is deprecated." Suggestions?Thanks,Mike
7
0
2.0k
Jan ’18