List to List view in SwiftUI?

Hi all!!

I have a navigation view with a list in ContentView. What do I need to do in my DetailView to open another List of data when you click on each individual cell. (Currently I can only get it to open one cell of data on the detailView - not another dynamic list)

Any tips?

THank you!

@toothdoc
Hi Jacob

Probably best to share your code to show what you have attempted to do to get it to work.

If I understand you correctly, your list of data in ContentView is different to the data you intend to display in DetailView but in some way that DetailView data is dependant on which row is selected in ContentView. Is that kind of what is going on?

Hello Chris,

Thank you.

Yes what you are asking is exactly what I am curious about! I am building the iDine app and out of total curiosity am trying to learn how to change it for a future project.


So currently when you click on a menu item, it opens up into one single view with photo and text. But how would you make it so if you click on any menu item, it opens up another list of data you are pulling from your json file?

Thank you Chris!

-Jacob

The same json file or a different one?

I was thinking the same json file but as a beginner did not even know I could implement multiple json files.

For example, I just changed the data quicklike and the names and a few variables from the json data and made this show up to kind of show what I am envisioning - As you can see, when I click on the field, only one spanish/english pair come up. How would I code it to show a dynamic list?

If you want to use the same json file then it will need to be structured in a way that it makes it really easy for you can get the data you want.

Is the json that you are creating only to hold static data or is it ultimately going to be dynamic as would be the case if you are extracting it from a datasource via an API?

Since this is my first app, I would like to start more simple - static data and just have everything load into the app bundle.

As far as structuring the json - what is the easiest/most efficient way in your opinion? I am envisioning a parent like “Orthodontics” and inside of it having an array of dictionary (english:spanish) – does this sound totally crazy haha? And then of course having one of these “orthodontic” parent objects for every field listed.

I’ve seen a utility on line where you can convert a JSON file to CSV format and back again so that might be the way to go about it. Configure your data in a spreadsheet and then convert it into JSON using that utility.

Google JSON to CSV and you should find it.