title: Call Method From Another View Controller iOS StoryBoard
body: <p>I have a table view cell with a button that, when pressed, needs to call the method of a different view controller.  I''ve followed this <a href="http://www.raywenderlich.com/5138/beginning-storyboards-in-ios-5-part-1" rel="nofollow">tutorial</a>, which shows one way to get at another view controller in story boards, but it involves hardcoding the position of the view controllers.  Anytime I'd change the order of my view controllers, I'd need to update my code, which I know I will mess up.</p>
  
  <p>Here is their method:</p>
  
  <pre><code>UITabBarController *tabBarController = (UITabBarController *)
  self.window.rootViewController;
  UINavigationController *navigationController = 
  [[tabBarController viewControllers] objectAtIndex:0];
  PlayersViewController *playersViewController = 
  [[navigationController viewControllers] objectAtIndex:0];
  playersViewController.players = players;
  </code></pre>
  
  <blockquote>
    <p>Yikes, what is that?! We want to assign the players array to the
    players property of PlayersViewController so it can use this array for
    its data source. But the app delegate doesn’t know anything about
    PlayersViewController yet, so it will have to dig through the
    storyboard to find it. This is one of the limitations of storyboards
    that I find annoying. With Interface Builder you always had a
    reference to the App Delegate in your MainWindow.xib and you could
    make connections from your top-level view controllers to outlets on
    the App Delegate. That is currently not possible with storyboards. You
    cannot make references to the app delegate from your top-level view
    controllers. That’s unfortunate, but we can always get those
    references programmatically.</p>
  </blockquote>
  
  <p>Does anybody know a cleaner way?</p>
  
  <p>I tried creating an IBOutlet in my table view cell to the other view controller, but I can't ctrl-click and drag to the other view controller for some reason.</p>
  
  <p>I also tried setting the IBAction of my button in my other view controller, but I need to know what row was clicked, and the only information i can get from <code>-(IBAction) addButtonClicked:(id)seder</code> is the <code>sender</code> information, which is just <code>RectButton</code>.</p>
  
  <p>Thanks!</p>