title: Setting textLabel.text in UITableView using JSON data
body: <p>I will preface the question with I am new to iOS and could use a little push. I have been trying to figure this out for a few days and fear I am not able to figure out the solution out of my frustration. It is my hope that some new eyes backed with experience will be able to help me out with this.</p>
  
  <p>I have a JSON file that I want to use for various portions of my application. The file can be viewed at <a href="https://raw.github.com/irong8/stronger-nation-data/master/data.json" rel="nofollow">https://raw.github.com/irong8/stronger-nation-data/master/data.json</a> for reference.</p>
  
  <p>I am using Storyboards and want to accomplish this using the built in JSON support of iOS5. I created a new TableViewController subclass and have included the code below.</p>
  
  <p><strong>Here is my .h file</strong></p>
  
  <pre><code>#import &lt;UIKit/UIKit.h&gt;
  
  @interface StateTableViewController : UITableViewController
  {
      NSArray *StateList;
  }
  
  @property (nonatomic, retain) NSArray *StateList;
  
  - (void) buildStateList;
  
  @end
  </code></pre>
  
  <p><strong>Here is my .m file</strong></p>
  
  <pre><code>#import "StateTableViewController.h"
  
  @implementation StateTableViewController
  
  @synthesize StateList;
  
  - (void)buildStateList {
      NSString *jsonFile = [ [NSBundle mainBundle] pathForResource:@"data" ofType:@"json" ];
      NSError *jsonError = nil;
  
      NSData *jsonData = [NSData dataWithContentsOfFile:jsonFile options:kNilOptions error:&amp;jsonError ];
      NSDictionary *json = [NSJSONSerialization JSONObjectWithData:jsonData options:0 error:&amp;jsonError];
  
      NSArray *jsonArray = [json objectForKey:@"states"];
  
      self.StateList = jsonArray;
  }
  
  - (void)viewWillAppear:(BOOL)animated
  {
      [super viewWillAppear:animated];
      [self buildStateList];
  }
  
  - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  {
      return 1;
  }
  
  - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  {
      return [StateList count];
  }
  
  - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  {
      static NSString *CellIdentifier = @"Cell";
  
      UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
      if (cell == nil) {
          cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
      }
  
      cell.textLabel.text = [NSString stringWithFormat:@"%d", indexPath.row];
  
      return cell;
  
  }
  </code></pre>
  
  <p>I can loop through the StateList array using the following and see the state names I am looking for.</p>
  
  <pre><code>for (NSString *element in StateList) {
      NSLog(@"element: %@", element);
  }
  </code></pre>
  
  <p>When I load this view, a TableView is loaded with 50 rows (as expected as there are 50 state records in my data file) and each row is numbered 0-49. I am having trouble figuring out how to access the state name in my StateList array. </p>
  
  <p>Any help along the way would be much appreciated!</p>