title: How to reference tableView from a view controller during a segue
body: <p>I'm new to iOS development, so go easy on me please :)</p>
  
  <p>Using Xcode 4.2 for iOS 5, I've built a view controller in IB, with a tableview inside it linked to a detail view controller through a push segue (at table view cell level)</p>
  
  <p>I'm wanting to setup the detail pages labels with data from my datasource based on the index of the cell selected.  Initially I coded the "didSelectRowAtIndexPath" only to find out that this is called after the segue processing, and found out that I need to call prepareForSegue instead</p>
  
  <p>My problem is, that whatever I try, as tableView is not a passed parameter to prepareForSegue (unlike most other methods I've used thus far), I'm struggling to get access to the tableView within the view controller in order to call the indexPath method, such that I can reference my datasource</p>
  
  <p>I've seen many examples using self, as below, but this results in an error stating that tableView doesn't exist within the view controller</p>
  
  <pre><code>- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  
    NSIndexPath *selectedIndexPath = [self.tableView indexPathForSelectedRow];
    DetailViewController *detail = [segue destinationViewController];
    detail.primary = [datasource objectAtIndex:selectedIndexPath.row];
    detail.seconday = [datalist objectForKey:detail.primary];
  }
  </code></pre>
  
  <p>I've also tried using</p>
  
  <pre><code>ViewController *main = [segue viewController];
  </code></pre>
  
  <p>Instead of using self, but this results in the same issue</p>
  
  <p>I know that I could rewrite the example to be a Table View Controller instead, but wanted to know if it was possible this way ?  As I've seen people use both methods in development</p>
  
  <p>For reference, I was following this tutorial ... <a href="http://kurrytran.blogspot.com/2011/10/ios-5-storyboard-and.html" rel="noreferrer">http://kurrytran.blogspot.com/2011/10/ios-5-storyboard-and.html</a></p>
  
  <p>When I got to the section for completing the detail page, I thought, why not use a segue to link the table view cell to the detail page, and code up the copying of the state and capital prior to the detail page being displayed.  As you can see from this tutorial, the main controller is a view controller</p>
  
  <p>My understanding was that NOT using an UITableViewController would give any app greater flexibility should it need to develop into something more complex later on</p>
  
  <p>Hope you can help,
  Izzy</p>