Post

Replies

Boosts

Views

Activity

Why have xcuserstate and xcschememanagement started preventing every merge
I'm using xcode 15.1 with git version control and was happily committing and pushing branches and merging them back into main. Until a couple of days ago, when every attempt to merge started being met with a 'you have uncommitted changes' message, and the files above being named. Sometimes I can commit the 'changes' and merge but sometime I'm asked to compare changes in files I cant even read in xcode and I cant proceed.
0
0
315
Dec ’23
Working with the web guided Restaurant app project - submit order data is missing
I'm working through the data collections course and am on the final steps of the restaurant app project. Everything is working except the final submit order API call. When the submit button is tapped, this IBAction calls uploadOrder(): @IBAction func submitOrderTapped(_ sender: Any) {     let orderTotal = MenuController.shared.order.menuItems.reduce(0.0) {       (result, menuItem) -> Double in       return result + menuItem.price     }     let formattedTotal = orderTotal.formatted(.currency(code: "usd"))           let alertController = UIAlertController(title: "Confirm Order", message: "You are about to submit your order with a total of \(formattedTotal)", preferredStyle: .actionSheet)     alertController.addAction(UIAlertAction(title: "Submit", style: .default, handler: { _ in self.uploadOrder()             }))     alertController.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: nil))           present(alertController, animated: true, completion: nil)   } uploadOrder calls the shared submitOrder fuction: func uploadOrder(){     let menuIDs = MenuController.shared.order.menuItems.map {$0.id}     Task.init {       do {         let minutesToPrepare = try await MenuController.shared.submitOrder(forMenuIDs: menuIDs)         self.minutesToPrepareOrder = minutesToPrepare         self.performSegue(withIdentifier: "confirmOrder", sender: nil)       } catch {         displayError(error, title: "Order Submission Failed")       }     }   } And submitOrder posts to the provided order API endpoint:  func submitOrder(forMenuIDs menuIDs: [Int]) async throws -> MinutesToPrepare {     let orderURL = baseURL!.appendingPathComponent("order")     var request = URLRequest(url: orderURL)           request.httpMethod = "POST"     request.setValue("application/json", forHTTPHeaderField: "Content-Type")           let menuIdsDict = ["menuIds": menuIDs]     let jsonEncoder = JSONEncoder()     let jsonData = try? jsonEncoder.encode(menuIdsDict)           request.httpBody = jsonData     let (data, response) = try await URLSession.shared.data(for: request)     guard let httpResponse = response as? HTTPURLResponse, httpResponse.statusCode == 200 else {       throw menuControllerError.orderRequestFailed     }     let decoder = JSONDecoder()     let orderResponse = try decoder.decode(OrderResponse.self, from: data)           return orderResponse.prepTime   } Everything is basically by the book, but when uploadOrder is called, the error statement fires and displays "Order submission failed" and "The data couldn't be read because it is missing" I'm trying to debug but unsuccessfully so far. Help appreciated.
1
0
316
Feb ’23
Favorite Athlete Lab - Cell reuse identifier not found in scope
I'm working on the Favorite Athlete Lab - trying to complete it while accepting I don't understand everything it is teaching yet. I've encountered many challenges with the Lab but the current on is: I've set the cell reuse identifier of my cell to 'drinkCell' in the attributes inspector - but when I use it in the scenes ViewController, I get the error "can not find 'drinkCell' in scope". I can see from the teacher resources how this has been solved there, but as far as I can tell, this solution has not be taught at any point so far, and isn't even mention in the subsequent section on cell dequeuing. let cell = tableView.dequeueReusableCell(withIdentifier: drinkCell, for: indexPath) Any help understanding this much appreciated.
0
0
507
Jan ’23
Favorite Athlete Lab - Fatal error thown when performing 'Add Athlete' SegueAction
I'm working through the Favorite Athlete Lab in the Develop in Swift Data Collections book. The guide says: In the addAthlete method, instantiate and return a new instance of AthleteFormViewController. When I control-dray to create the IBActionSegue, I am given the code: @IBSegueAction func addAthlete(_ coder: NSCoder) -> AthleteFormViewController? {     return <#AthleteFormViewController(coder: coder)#>   } I'm not sure what I should add but I currently have: @IBSegueAction func addAthlete(_ coder: NSCoder) -> AthleteFormViewController? {     let newViewController = AthleteFormViewController(coder: coder)     return newViewController   } When I run the app and click the button connected to the Segue Action, the required init on the View Controller gives the error: Fatal error: init(coder:) has not been implemented I dont know if the way I instantiate and return AthleteFormViewController is the issue, but it seems to be where it goes wrong and where I dont understand quite what is required. Update: Got it working. The problem did not seem to be the way I created and returned the instance, but the auto-added required init on the target View Controller. Xcode's fix supplied:  required init?(coder: NSCoder) {     fatalError("init(coder:) has not been implemented")   } But I had to change this to: required init?(coder: NSCoder) {     super.init(coder: coder)   } What I'm trying to work out now is if I should have known this already? I did not.
2
0
960
Jun ’22