title: iOS TableView Hierarchy using NSArray with ARC, how to repopulate array?
body: <p>Thanks in advance.</p>
  
  <p>Currently working on an application for university that consists of a tab bar controller that contains two view controllers, the first is irrelevant and the second is a navigational controller. That navigational controller consists of a tableView containing various campus Buildings (from an NSArray) that the user can select. The navigational controller also contains another View Controller called BuildingFloorsViewController itself has another table itself containing the various Floors in an NSArray called floors (Ground Floor, First Floor etc)  for the chosen building. </p>
  
  <p>So the idea is that the same NSArray (floors) will repopulate depending on which building is selected. Is this a bad idea? </p>
  
  <p>At the moment what happens is that the table takes the form of which ever row in the previous table is selected - which makes perfect sense as the table is being initiated there and then. So for example if I select the London Road row first, it'll create the array with 4 values (+ nil) but if I select the Faraday Ring row first it'll create the array with 3 values (+ nil).</p>
  
  <p>So, how do I go about providing a different set of values for each if-statement condition? I've looked at using a mutable array and just adjusting the values but is there another way?
  Thanks.</p>
  
  <p>Here's the code for BuildingFloorsViewController.h</p>
  
  <pre><code>#import &lt;UIKit/UIKit.h&gt;
  
  @interface BuildingFloorsViewController : UITableViewController{
      NSArray *floors;
      NSArray *londonRoadFloors;
  }
  @property (nonatomic, retain) NSArray *floors;
  @property (nonatomic, retain) NSArray *londonRoadFloors;
  
  @end
  </code></pre>
  
  <p>And BuildingFloorsViewController.m</p>
  
  <pre><code>#import "BuildingFloorsViewController.h"
  
  @interface BuildingFloorsViewController ()
  
  @end
  
  @implementation BuildingFloorsViewController
  @synthesize floors;
  @synthesize londonRoadFloors;
  
  -(void)viewWillAppear:(BOOL)animated {
  if([self.title isEqualToString:@"Farady Wing"]){
      floors =[[NSArray alloc]
              initWithObjects:@"First Floor",@"Second Floor",@"Third Floor",nil];
  }else if([self.title isEqualToString:@"London Road"]){
      floors =[[NSArray alloc]
              initWithObjects:@"Ground Floor",@"First Floor",@"Second Floor",@"Third Floor",nil];
      }
  }
  
  
  - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
  {
      self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
  
      if (self) {
      // Custom initialization
      }
      return self;
  }
  
  - (void)viewDidLoad
  {
      [super viewDidLoad];
      // Do any additional setup after loading the view from its nib.
  }
  
  - (void)viewDidUnload
  {
      [super viewDidUnload];
      // Release any retained subviews of the main view.
      // e.g. self.myOutlet = nil;
  }
  
  - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
  {
      return (interfaceOrientation == UIInterfaceOrientationPortrait);
  }
  - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
  // Return the number of sections.
  return 1;
  }
  
  - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  // Return the number of rows in the section.
  return [floors count];
  }
  
  - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  {
  static NSString *CellIdentifier = @"Cell";
  tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
  UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
  if (cell == nil) {
      cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
      cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
  }
  
  cell.textLabel.text=[self.floors objectAtIndex:[indexPath row]]; 
  return cell;
  }
  
  -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 
  //&lt;#RoomViewController#&gt; *roomViewController = [[&lt;#RoomViewController#&gt; alloc] initWithNibName:@"&lt;#Nib name#&gt;" bundle:nil];
  </code></pre>
  
  <p>}
      @end</p>