Post

Replies

Boosts

Views

Activity

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 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 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 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 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 Where to learn this world?
I googled it, i'm afraid that i'm going on the wrong way. Seems you are not good at googling. With searching on the web you can find many many resources to learn Swift. Some of them may be good, and many of them may not. And I need a few sources where I can learn all of this stuff. If you insist on learning only a few you would never be able to learn Swift. People who are developing practical apps in Swift have learnt Swift through many resource, not a few. Better start with a few from you can find, and you may need more if they are not sufficient for you. Apple's tutorials - https://developer.apple.com/tutorials/SwiftUI may be a good starting point, but cannot say if it would be the best for you or not.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
May ’21
Reply to Extending AppStorage to be compatible with Int32
I tried extending AppStorage to include an initializer with a RawRepresentable that has Int32 as rawValue but I can't find what to include in it to make it work. I cannot find any public APIs in AppStorage to implement another initializer. You may need another way around for this issue. @AppStorage("locationSettings") var rawLocationSettings: Int = Int(CLAuthorizationStatus.notDetermined.rawValue) var locationSettings: CLAuthorizationStatus { get { return CLAuthorizationStatus(rawValue: Int32(rawLocationSettings))! } set { rawLocationSettings = Int(newValue.rawValue) } } Please share your solution when you find a better way.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
May ’21
Reply to SwiftUI App crash after keyboard show
@OOPer, this case like my video. open app - click show second view - click change Change state - focus to "ple" TextField - show keyboard and crash. Thanks for showing the steps. I could reproduce the issue with doing as instructed. In my opinion, this is a bug of the current implementation of SwiftUI. But you would not be able to wait until this issue is fixed by Apple, and may need sort of workarounds. In fact, I was searching for some workarounds for the steps I have shown, no avail till now. I will show you when I find some workaround which works steadily enough.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
May ’21
Reply to SwiftUI App crash after keyboard show
You may have tried already (and this may be difficult to apply to your actual app), but this is the only workaround I could have found till now: struct ContentView: View { @State var tradingMode : TradingMode = TradingMode.Equities @State var isShowSecondView = false var body: some View { VStack(content: { Button("show second view") { isShowSecondView.toggle() } TabView { switch tradingMode { case .Equities: VStack(content: { Text("Tab 1 Un") .padding() TextField("ple", text: .constant("")) }) .tabItem { Text("tab 1") }.tag(0) VStack(content: { Text("Tab 2 Un") .padding() TextField("ple", text: .constant("")) }) .tabItem { Text("tab 2") }.tag(1) case .Derivatives: VStack(content: { Text("Tab 1 Der") .padding() TextField("ple", text: .constant("")) }) .tabItem { Text("tab 1") }.tag(0) VStack(content: { Text("Tab 2 Der") .padding() TextField("ple", text: .constant("")) }) .tabItem { Text("tab 2") }.tag(1) } } }) .sheet(isPresented: $isShowSecondView, content: { SecondView(tradingMode: $tradingMode) }) } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
May ’21
Reply to Issue with Xcode
Thanks for clarification. So, you are trying to build and run the Xcode project created by Visual Studio (for Mac) / Xamarin. The error you mentioned would happen when the project is not properly made for the version of Xcode you are using. It is a problem of Visual Studio / Xamarin, not a problem of Xcode. Visual Studio is not a tool of Apple's and you should better find a community site or a supporting site of Visual Studio / Xamarin.
May ’21