title: Making connections between Main.storyboard and AppDelegate.h
body: <p>With Xcode 5.0 I am trying to follow the <a href="http://www.bignerdranch.com/books" rel="nofollow noreferrer">Big Nerd Ranch book</a> 2nd edition, which seems to be a bit outdated.</p>
  
  <p>There is an example Quiz project with 2 labels and 2 buttons.</p>
  
  <p>I have copied the source code from the book, esp. the <code>AppDelegate.h</code>:</p>
  
  <pre><code>#import &lt;UIKit/UIKit.h&gt;
  
  @interface AppDelegate : UIResponder &lt;UIApplicationDelegate&gt; {
      int currentQuestionIndex;
      NSMutableArray *questions;
      NSMutableArray *answers;
      IBOutlet UILabel *questionField;
      IBOutlet UILabel *answerField;
  }
  
  @property (strong, nonatomic) UIWindow *window;
  - (IBAction)showQuestion:(id)sender;
  - (IBAction)showAnswer:(id)sender;
  
  @end
  </code></pre>
  
  <p>There is no <code>MainWindow.xib</code> mentioned in the book, but I do have a <code>Main.storyboard</code>, where I'v placed the labels and buttons:</p>
  
  <p><img src="https://i.stack.imgur.com/mXCIU.png" alt="screenshot"></p>
  
  <p>I can see the 4 hollow little circles at the left side of source code editor (in the middle of the above screenshot) and in the "Connection Inspector" (for example "Touch Up Inside"), but I just can't get them connected. I tried dragging and ctrl-dragging from the little circles to the buttons/labels, there is a blue line, but it doesn't connect.</p>
  
  <p>And when I right-click the buttons/labels, then a grey menu about "Outlets" appears, but none of my IBOutlets/IBActions are listed there.</p>
  
  <p>How can I add the connections to the labels and buttons please?</p>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>On Rob's advice (thank you +1) I've moved the properties and methods to <code>ViewController.*</code> and been able to connect the labels and buttons. I see the methods being called, when I click the buttons.</p>
  
  <p>But now I have the problem that the <code>init</code> method of the <code>ViewController</code> class is not run and thus both arrays are nil.</p>
  
  <p>Any further hints please? And I'm not sure why the suggestions to close my question as "too broad" - I have attached the (short) code and the screenshot and my 2 questions are pretty specific (and probably basic).</p>
  
  <p><strong>ViewController.h:</strong></p>
  
  <pre><code>#import &lt;UIKit/UIKit.h&gt;
  
  @interface ViewController : UIViewController {
      int currentQuestionIndex;
      NSMutableArray *questions;
      NSMutableArray *answers;
      IBOutlet UILabel *questionField;
      IBOutlet UILabel *answerField;
  }
  - (IBAction)showQuestion:(id)sender;
  - (IBAction)showAnswer:(id)sender;
  
  @end
  </code></pre>
  
  <p><strong>ViewController.m:</strong></p>
  
  <pre><code>#import "ViewController.h"
  
  @interface ViewController ()
  
  @end
  
  @implementation ViewController
  
  - (id)init {                 // XXX is never called??
      self = [super init];
  
      if(self) {
          questions = [[NSMutableArray alloc] init];
          answers = [[NSMutableArray alloc] init];
  
          [questions addObject:@"What is 7 + 7?"];
          [answers addObject:@"14"];
          [questions addObject:@"What is the capital of Vermont?"];
          [answers addObject:@"Montpelier"];
          [questions addObject:@"From what is cognac made?"];
          [answers addObject:@"Grapes"];
      }
  
      return self;
  }
  
  - (IBAction)showQuestion:(id)sender // XXX runs ok when clicked
  {
      currentQuestionIndex++;
      if (currentQuestionIndex == [questions count]) {
          currentQuestionIndex = 0;
      }
  
      NSString *question = [questions objectAtIndex:currentQuestionIndex];
      NSLog(@"displaying question: %@", question);
      [questionField setText:question];
      [answerField setText:@"???"];
  }
  
  - (IBAction)showAnswer:(id)sender  // XXX runs ok when clicked
  {
      NSString *answer = [answers objectAtIndex:currentQuestionIndex];
      [answerField setText:answer];
  }
  
  - (void)viewDidLoad
  {
      [super viewDidLoad];
  }
  
  - (void)didReceiveMemoryWarning
  {
      [super didReceiveMemoryWarning];
  }
  
  @end
  </code></pre>