Post

Replies

Boosts

Views

Activity

Reply to How can I format a space that is entered into textfield and code the space into a URL?
What's the best way to incorporate the possibility of a space being entered in a name in the text field, and then formatting that string w/a space into a URL? I cannot say what would be the best, but can say using URLComponents would be a very preferable way: struct APIManager { //let dataURL = "https://api.openweathermap.org/data/2.5/weather?appid=MyAPIID&units=imperial" let weatherURL = "https://api.openweathermap.org/data/2.5/weather" let MyAPIID = "MyAPIID" var delegate: APIManagerDelegate? func fetchData(location: String) { var urlComponents = URLComponents(string: weatherURL)! urlComponents.queryItems = [ URLQueryItem(name: "appid", value: MyAPIID), URLQueryItem(name: "units", value: "imperial"), URLQueryItem(name: "q", value: location), ] performRequest(url: urlComponents.url) /*print(urlComponents.url)*/ } func performRequest(url: URL?) { if let url = url { let session = URLSession(configuration: .default) let task = session.dataTask(with: url) { (data, response, error) in if error != nil { print(error!) return } if let safeData = data { self.parseJSON(cityData: safeData) } } task.resume() } } //... }
Topic: Programming Languages SubTopic: Swift Tags:
May ’21
Reply to X code on el captain
According to an article of Apple, MacBook Pro 2015 can run Big Sur (macOS 11.x). macOS Big Sur is compatible with these computers - https://support.apple.com/en-us/HT211238 MacBook Pro ... MacBook Pro (Retina, 15-inch, Mid 2015) MacBook Pro (Retina, 13-inch, Early 2015) First, upgrade your MacBook Pro to Big Sur (it's free!), and the install the latest Xcode version (currently 12.5). You may download some older version of Xcode and install it, More Downloads - https://developer.apple.com/download/more/ but please remember you need Xcode 12.x to build an app submitted to App Store. App Store submission update - https://developer.apple.com/news/?id=ib31uj1j
May ’21
Reply to The compiler is unable to time-check
But as you see in the following my code shouldn't actually be too complex I think. The compiler would not think as you think. Try this: let q1: [String] = ["Whoever can do more situps out of " + name[p1] + " & " + name[p2] + " gets two points.", name[p1] + " & " + name[p2] + " who is quicker to touch the ceiling? Winner gets a point.", ] Or this: let q1 = ["Whoever can do more situps out of \(name[p1]) & \(name[p2]) gets two points.", "\(name[p1]) & \(name[p2]) who is quicker to touch the ceiling? Winner gets a point.", ] Swift compiler is not good at parsing binary operations especially when they include literals. Adding type annotations would help in some simple cases, or not using binary operator would work.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
May ’21
Reply to How to exploit a vision function?
How can i build a test code in playground to get that list of animals identifier? The documentation says it is a throws class-method, taking a single parameter forRevision: of type Int, defined in the framework Vision: import Vision do { let identifiers = try VNRecognizeAnimalsRequest.knownAnimalIdentifiers(forRevision: VNRecognizeAnimalsRequest.defaultRevision) print(identifiers) //-[__C.VNAnimalIdentifier(_rawValue: Cat), __C.VNAnimalIdentifier(_rawValue: Dog)] } catch { print(error) } What is the general methodology to run such functions from the documentation? Better learn the basics of the Swift language.
Topic: Programming Languages SubTopic: Swift Tags:
May ’21
Reply to Calling a POST Form with URLSession.shared.dataTask
I put a print to see where code is passing and in immediate panel shows like this: Passed 01 =========== Passed 03 =========== Passed 04 =========== out off func!! 2021-05-04 11:41:16.460925-0300 Fuel[2348:100030] [] nw_protocol_get_quic_image_blockinvoke dlopen libquic failed Passou 02 =========== Status: true Nome: Roberto Pires  (I didn't understand libquic failed, but the problem is another one) Seems your code is working correctly. Well, the correct should be: NO, it is not correct. My code is called by a button, but returns BEFORE complete (and as so, show an incorrect Alert, because the "myJsonResponse?.status" is false at this time),  It is the right behavior, when you want to work with async methods. An async method itself returns to caller BEFORE complete, and the completion handler is executed after the task is completed. This is called by my Login Button: What is aspStatus? It does not appear in validatingLogin(). In the near future, you may need to learn async/await pattern in Swift, but you need to be accustomed with completion handler pattern until then. You need to write everything you want to run after the task is completed within the completion handler.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
May ’21
Reply to Calling a POST Form with URLSession.shared.dataTask
aspStatus is a Class that return to me true or false (if false, a message why its false): Thanks for showing the class. But you have not shown the declaration of aspStatus (I do not mean AspStatus), nor any code using the class AspStatus. So it does not give any useful info to me. I just don't understand your last part: In your case, from the opening brace { on line 13 of validatingLogin() to the closing brace } on line 34 is the completion handler.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
May ’21
Reply to Help with documentation : example: DisclosureGroup
my problem is with api documentation like we discuss earlier  In fact, the documentations of SwitfUI are far worse than poor. Maybe some words which are excluded from this site would be appropriate. I really wonder why Apple's engineers (not Document engineer, but the designers and the implementers) are not interested in writing a good documentation. But one reason you cannot read them well is that you assume things where it is not expected. You first assumed <Label, Content> would define the parameters of an initializer, but it does not. And even in C sharp, generic parameters does not define the parameters of a constructor. I do agree that SwiftUI forces us some different aspects than that of procedural programming, but there are many of such things waiting for you and stopping on a type header does not seem to be a good attitude. Anyway, check the documentation of the initializer when you want to call init of a struct.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
May ’21
Reply to nil on unwrapping ScrollView
My application crashes when I call the ViewController of the slider.  How are you showing the view controller? Using segue? Or something else? And please show the whole message you get and which line it happens.
Topic: UI Frameworks SubTopic: UIKit Tags:
May ’21
Reply to nil on unwrapping ScrollView
Thanks for showing the code. This is the worst part of your code: IntroSliderViewController() You are calling the undocumented initializer init() of IntroSliderViewController, in almost all cases, it would create a garbage object which causes Fatal error: Unexpectedly found nil. When you want to instantiate a view controller that you have defined on the storyboard with subviews and/or IBOutlets/IBActions, you need to instantiate it through the storyboard. Like this: let introSliderVC = self.storyboard?.instantiateViewController(withIdentifier: "IntroSliderViewController") self.present(introSliderVC, animated: true, completion: nil) (You need to put the right Storyboard ID IntroSliderViewController to the view controller in the Identity Inspector.)
Topic: UI Frameworks SubTopic: UIKit Tags:
May ’21