Post

Replies

Boosts

Views

Activity

Reply to Store Location from API into Array
The print statement on line 21 prints out the google api page There's no print statement on line 21 of my code, is it line 11? And you mean the URL string by the google api page? It would be far better copying all the outputs in the debug console than trying to describe them by words. then nothing else is printed until line 51, "value for location not found or not string". It is strange and would never happen. If line 51 would be executed, line 30 print(String(data: data, encoding: .utf8) ?? "?") is definitely executed.  I did try change the array type to double but same output.  Please show your code when talking about changing code. I really do not understand what you have tried. When I switch, on line 46, the key value to "name" it is still able to store the values of name into the array and prints out properly. I do not understand what you mean. What is switch? What is able to store the values? Please show actual code you used and actual output you saw. I've been picking parts from different forums to try and make this app. Seems you have chosen a very bad one. If you find NS-something in a code, you should better avoid it. (A little bit too simplified, but would be useful in many cases -- avoid NS-things.)
Topic: Programming Languages SubTopic: Swift Tags:
Jan ’21
Reply to Store Location from API into Array
This is the entire printed console when the code is ran:  Thanks for showing the output, but the JSON, outermost structure is JSON object must start with { (opening brace). Seems a few lines are missing. Can you show really entire output? (UPDATE) Can you show really entire output? Sorry, but no thank you. Seems your Console Out contains outputs of two runs. The first 936 lines for the first run -- partial, and the latter for the second run -- entire. Found what's wrong -- there's no entry of type String for the key "location" in the response. Need some time to write a more detailed answer...
Topic: Programming Languages SubTopic: Swift Tags:
Jan ’21
Reply to Store Location from API into Array
When the print statement is within the do brackets, it shows it is filled, but once its after the task.resume(), it will only show a populated array after the second execution  You may be handling asynchronous method in a bad way. Which may caused by your hidden parts of code and that is another issue. You should better start a new thread which includes all relevant parts. Please do not ask things which is not included in the opening post. Keep one thread for one topic.
Topic: Programming Languages SubTopic: Swift Tags:
Jan ’21
Reply to Array Only Shows Populated After Second Run Through
Have I somehow cleared the arrays without knowing? NO. You are using Arrays before they are populated. dataTask is an asynchronous call. The completion handler (line 25 { ... line 82 }) is executed after the task is complete. That printNames() on line 84 is executed before the task is completed. How to fix may depend on how you want to use the Arrays. Again, you are not showing the code using the Arrays.
Topic: Programming Languages SubTopic: Swift Tags:
Jan ’21
Reply to Array Only Shows Populated After Second Run Through
The gotoplaces() function is what utilizes the arrays: Thanks for showing the code. Then you need to call gotoaces() or (gotoplaces() or gotoPlaces()?) inside the completion handler. I thought that since the function was called after task.resume() meant that it finished? It is a very common misunderstanding among who are not accustomed to async call. task.resume() just triggers to start the task. When the task is finished, iOS tell your app that the task is completed. Another too simplified advice: Do not write any lines after task.resume().
Topic: Programming Languages SubTopic: Swift Tags:
Jan ’21
Reply to Can you turn off buffer overflow protections?
any password of 9 or more characters ny password of 13 or more characters Seems you want to ignore the fact that there were no description about what you had input on SIGABRT. And you expect some specific memory allocation on auto variables. Anyway, please clarify the difference between what you expect and what you actually get, for each possible inputs. Some of them may be caused by buffer overflow protections, and some other by your wrong expectations.
Jan ’21
Reply to Did Xcode 12.4 get rid of "storyboards" by default?
things have changed in 12.4.  Things had changed in 12.0. For instance there's no more AppDelegate.swift file. I would start at class ViewController: UIViewController before. Now there's struct ContentView: View  which I don't recall when in started learning in late 2020. Do I need to repeat? When you choose Storyboard as Interface` when creating a new project, you can find AppDelegate.swift or ViewController.swift. And then you can remove what you think is not needed for you. Is it that I never used SwiftUI? At lease in your past posts, you have never used SwiftUI.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Feb ’21