Post

Replies

Boosts

Views

Activity

Reply to Add Return key subview to keyboard
I need to add a Return key to a numeric keyboard (BTW, how is it it does not exist in standard ?) Any chance you can just do this with an inputAccessoryView? That’s a supported API and It Just Works™. I guess I have to add subview to something else than UITextEffectsWindow (keyBoardWindow), but to what ? I’m sure you know this already, but (for those in the wider audience who may not know) poking around in a private, undocumented view hierarchy is fragile and unsupported. That way madness lies.
Topic: UI Frameworks SubTopic: UIKit Tags:
Jun ’22
Reply to Swift Post request ,Django backend
what should I do? Provide more information about your problem. 😉 What is that “result” string: the body of the server response, something in the server log, something else? Assuming you get a valid HTTP response (though not shown in your code), what is the status code: 200? 4XX? What is the body of the response? You don’t set a Content-Type: application/json header. Does your server require that header in order to handle the request?
Topic: App & System Services SubTopic: Core OS Tags:
Jun ’22
Reply to TabularData Framework: crash on opening CSV file
First, consider submitting a bug report and then post the Feedback ID here. But unfortunately I think the biggest issue may be this line in the documentation: Import, organize, and prepare a table of data to train a machine learning model. That sounds like the whole tabular data API is intended as a developer tool rather than a general-purpose CSV parser for production code. So it’s not totally unreasonable if it assumes well-formed data comes from upstream in your workflow and throws a fatal error if this precondition doesn’t hold. Look in your debug output for helpful troubleshooting messages like the ones @eskimo quoted above. Since you need bulletproof parsing and error handling for untrusted user-supplied data, this API probably isn’t the best tool for the job.
Topic: Machine Learning & AI SubTopic: General Tags:
Jun ’22
Reply to problem with a series of if statements
Definitely unexpected based on the limited code you posted. I’d add more sanity checking by also printing the value of the tested value within each block: if viewModel.npH < 7.35 { diagnos.resultado1 = "acidemia" print("4", viewModel.npH) } Does this turn up any incorrect assumptions?
Topic: UI Frameworks SubTopic: SwiftUI Tags:
May ’22
Reply to What would be the proper Syntax
Or if you want to skip ahead to more advanced Swift usage (without the early return optimization), consider this: func isPassingGrade(for scores: [Int]) -> Bool {     scores.reduce(0, +) >= 500 } There’s no explicit sum() function in the Swift library but this reduce() expression is equivalent. And reduce() is well worth getting familiar with.
Topic: Programming Languages SubTopic: Swift Tags:
May ’22
Reply to When decoding a Codable struct from JSON, how do you initialize a property not present in the JSON?
Add an enum CodingKeys to your struct to declare exactly which properties are to be decoded. Simplified example: struct Reminder: Identifiable, Decodable { let id = UUID().uuidString let title: String enum CodingKeys: CodingKey { case title // note that id is not listed here } } See Encoding and Decoding Custom Types for more. If you also want to later encode the structure but include the id property, then you need to customize init(from:) and/or encode(to:) as described in the Encode and Decode Manually section.
Topic: Programming Languages SubTopic: Swift Tags:
May ’22
Reply to Is there an order for response, data, and error in URLSession delegates?
Also, a couple minor adjustments: if let httpResponse = response as? HTTPURLResponse { It’s generally safe to force the response as! HTTPURLResponse. If that optional binding were to actually fail, what then? extension UploadInv: UIDocumentPickerDelegate, URLSessionDataDelegate, URLSessionTaskDelegate, URLSessionDelegate You don’t need to list URLSessionDelegate or URLSessionTaskDelegate there, because URLSessionDataDelegate already extends them. I’m a little surprised there isn’t a compiler warning for that.
Topic: Programming Languages SubTopic: Swift Tags:
May ’22
Reply to Is there an order for response, data, and error in URLSession delegates?
Well urlSession(_:task:didCompleteWithError:) always gets called last because it indicates the end of the task. And urlSession(_:dataTask:didReceive:completionHandler:) (response headers) needs to get called before urlSession(_:dataTask:didReceive:) (body) because depending on how you call the completion handler, it can change how the body gets handled subsequently. And it’s just natural that your code would receive the headers before the body. But for your situation, I think you can simplify by eliminating the response method entirely. Note the documentation says it’s intended for specific cases that don’t seem to apply here. Instead, just check the error and HTTP response code in the completion method, and then process the accumulated body data as needed. (Or if you keep the response method, note you need to call the completion handler to tell the system what to do next. The documentation isn’t clear on whether you should call it synchronously or asynchronously. Seems to me you should call it synchronously since it seems to work like a function return value, but I may be missing something subtle there.)
Topic: Programming Languages SubTopic: Swift Tags:
May ’22