Post

Replies

Boosts

Views

Activity

Reply to Files Missing after Creating Branch
I don't even see a .git folder in the root directory. I had at least 20-30 files. I don't quite remember all of the steps I took. What I remember is I added a file to one of the branches, and went to switch to see if it only added the file in one of the branches. After that, both ended up empty. I have a revision on my phone and simulator. Is there any way to recover the files with that?
3d
Reply to Most efficient way to call a function upon variable state change
Hi, I have a follow up question. In an older project, using that code, I get an error: 'onChange(of:initial:_:)' is only available in iOS 17.0 or newer The solution provided is to wrap the code in if #available(iOS 17.0, *) { }, but I'm only able to wrap the whole view inside of it, like so: if #available(iOS 17.0, *) { VStack () { // view with .onChange } } else { VStack () { // view with older solution } } The view is quite lengthy so it would be very redundant to have the same view twice, (the same view for each component of the if/else statement). Is there a way to implement an if statement so that I would only need the code for the view once (something like the code below)? VStack { } if #available(iOS 17.0, *) { .onChange() { } } else { // older solution }
Jul ’24
Reply to Incorrect JSON Format with JSONEncoder
Hi, Thank you for your response. Here is the whole function: func createAccount(account: AccountCreationData, completion: @escaping (Response) -> Void) { guard let url = URL(string: "http://localhost:4300/account/create-account") else { return } var request = URLRequest(url: url) request.httpMethod = "POST" print(account) guard let encoded = try? JSONEncoder().encode(account) else { print("Failed to encode request") return } print(encoded) request.httpBody = encoded URLSession.shared.dataTask(with: request) { (data, response, error) in guard let data = data else { return } do { let resData = try JSONDecoder().decode(Response.self, from: data) DispatchQueue.main.async { completion(resData) } } catch let jsonError as NSError { print("JSON decode failed: \(jsonError)") } }.resume() } Below are print statements of account and encoded: AccountCreationData(name: "name", email: "email", phone: "phone", password: "password") 110 bytes
Jul ’24