I'm creating an iOS app which allows you to find the quickest route from one city to another. To make things easier for the user, you can filter down based on a city's continent or country too (so Europe would show Paris, London and Berlin, whereas France would only show Paris). I currently have all my objects stored in various arrays, with the City object pointing to the Country object, and the Country object pointing to the Continent object. See my diagram below for a visual representation:
I feel that this is really ineffective when it comes to filtering the data out. I want a data structure that will allow me to filter the cities out quickly. I am happy to use my 3 arrays that I currently have, but I really feel that this isn't efficient enough, and I am struggling to find a solution online. Thanks in advance.
You are trying to set up a network type database. Instead, try using a relational type database. One table of cities with extra columns for country. Then another table of countries