Good day to all. Please help me think how best to implement such a thing. I have 2 screens and an API of this type:
[ { "страна": "тилимилитрямдия", "города": [ { "название" : "Июньск" "избранный": "да", } { "название" : "Июльск" "избранный": "нет", } ] }, { "страна": "Лапландия", "города": [ { "название" : "Декабрьск" "избранный": "да", } { "название" : "Январьск" "избранный": "нет", } ] } ] On the first screen, I have a collection view showing all cities without any divisions. On the second screen, I have to show all countries as a top dynamic menu (as there can be many countries coming) and below is a list of cities with the ability to filter this list if the user selects one or another country in the menu. Also, each item has a favorites button (a heart) by clicking on which the city falls into a favorite and the selected item is changed to - yes. Plus, somewhere on the screen there is a button favorites by clicking on which should be displayed only those cities and, accordingly, countries in the menu that are marked with a mark - yes.
For the menu and the list of cities, I made two collections with a view and a bunch of arrays with filters from which these collections are filled and constantly looped through. Everything works on the simulator, but the code is very cumbersome and not flexible. I'm just sure that the solution should be easier.
The problem is that I cannot figure out how to fill the cities with one array because the array has different countries and if you mix all the cities into one stream, then you will not be able to filter them.