title: Uitableview, json and detail tableview
body: <p>I am asking a very simple question for someone who has encountered this kind of problem, please don't mark it down because there are many approaches to a solution.</p>
  
  <p>I have  a database which has cities and town, cities has many town, therefore, using one query displays many cities to correspond to the town. The result is as follows from mysql;
  {City - town 1, town2, town 3} therefore if I want to display both the town and cities, I will end up with {city-town1, city-town2, city-town3}</p>
  
  <p>I want to be able to compile all towns under a city, so that I can eventually use this source of array for my drilldown table, i.e on the first table; I want a list of non-repeating cities, on detail table, a list of all towns under that city. I only want to use one table and make the array dynamic such that I can add cities and towns without any problems (I have seen examples proposing different tables for different arrays)</p>
  
  <p>I used this for- loop to iterate through mysql result</p>
  
  <pre><code>  for (int i=0; i&lt;json.count; i++)
              {
  
  
             ids= [[json objectAtIndex:i] objectForKey:@"Id"];
             cityName = [[json objectAtIndex:i] objectForKey:@"cityName"];
             townName = [[json objectAtIndex:i] objectForKey:@"townName"];
  }
  </code></pre>
  
  <p>This gives me a list of cities but they are repeating;</p>
  
  <p>I have been thinking about different approaches;
  1)use @distinctunion- (Key-Value Coding) 
  2)use two jsons (one for city and another for towns) -compile arrays under each then join them using common id
  3)use an iteration, iterate as shown above, but also search for similar cityNames and group towns under cities</p>
  
  <p>Has anyone encountered a similar situation? what did you do? could you  give an example if possible please</p>
  
  <p>This is JSON Result for NSMutable Array of the above iteration</p>
  
  <pre><code>    2013-09-18 07:50:52.025 JSONDATA[7119:11603] (
      Bath,
      "Bath, Somerset"
  )
  2013-09-18 07:50:52.035 JSONDATA[7119:11603] (
      Bath,
      "Bath, Somerset"
  )
  2013-09-18 07:50:52.035 JSONDATA[7119:11603] (
      Bath,
      Keynsham
  )
  2013-09-18 07:50:52.035 JSONDATA[7119:11603] (
      Bath,
      Keynsham
  
  )
  </code></pre>