title: How to reload a uitable when the row of a different uitable's row is selected
body: <p>I'm trying to reload a <code>UITableView</code> when the row of a different <code>UITableView's</code> row is selected. One of the problems I'm having is that both the <code>UITableView's</code> are in the same view. I would like a selection in Table1 to change the <code>NSMutableArray</code> that's used to populate Table2. And then reload the table.</p>
  
  <p>At the moment it works fine, but only when the app re-lauches (or the view is popped off the stack and then re-visited) and <code>viewWillAppear</code> is called again</p>
  
  <p>Here's my code:</p>
  
  <pre><code>- (void) viewWillAppear:(BOOL)animated {
      [super viewWillAppear:NO];
      [self.navigationController setNavigationBarHidden:YES animated:NO];
      self.navigationController.toolbarHidden = YES;
      NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
  
      // getting an NSString
      selectedTableString = [prefs stringForKey:@"selectedTableString"];
      if ([selectedTableString isEqualToString:@"Italy"]) {
          jsonStringCountry = @"http://****/v1/public/cities?country=it";
      }
      else if ([selectedTableString isEqualToString:@"Spain"]) {
          jsonStringCountry = @"http://****/v1/public/cities?country=es";
      }
      else if ([selectedTableString isEqualToString:@"UK"]) {
          jsonStringCountry = @"http://****/v1/public/cities?country=uk";
      }
      else if ([selectedTableString isEqualToString:@"Brazil"]) {
          jsonStringCountry = @"http://****/v1/public/cities?country=br";
      }
      NSLog(@"from two t selectedTableString %@",selectedTableString);
  
      // Download the yoodeal JSON
      NSString *jsonString = [NSString stringWithContentsOfURL:[NSURL URLWithString:jsonStringCountry] encoding:NSStringEncodingConversionAllowLossy|NSUTF8StringEncoding error:nil];
      NSLog(@"jsonStringCountry is %@", jsonStringCountry);
      NSMutableArray *itemsTMP = [[NSMutableArray alloc] init];
  
      // Create parser for the yoodeal api
      SBJSON *parser = [[SBJSON alloc] init];
      NSDictionary *results = [parser objectWithString:jsonString error:nil];
      itemsTMP = [results objectForKey:@"results"];
      self.displayItems = [itemsTMP copy];
  }
  </code></pre>
  
  <p>My <code>UITableView</code> methods:</p>
  
  <pre><code>- (int)numberOfSectionsInTableView:(UITableView *)tableView {
      return 1;
  }
  - (int)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
      return [displayItems count];
  }
  
  - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
      UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MainCell"];
      if(cell == nil){
          cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"MainCell"];
      }
  
      // Get item from tableData
      NSDictionary *item = (NSDictionary *)[displayItems objectAtIndex:indexPath.row];
      cell.textLabel.text = [item objectForKey:@"name"];
      [cell.textLabel setFont:[UIFont fontWithName: @"Asap-Bold" size: 14.0f]];
      return cell;
  }
  </code></pre>