title: Implementing delegate and protocol to pass data between views
body: <p>I'm having trouble implementing the protocol and delegate relationship described in this post:  <a href="https://stackoverflow.com/questions/5210535/passing-data-between-view-controllers?rq=1">Passing Data between View Controllers</a></p>
  
  <p>Under the "Passing Data Back" section, # 6 says:</p>
  
  <blockquote>
    <p>The last thing we need to do is tell ViewControllerB that
    ViewControllerA is its delegate before we push ViewControllerB on to
    nav stack.</p>
  </blockquote>
  
  <pre><code>   ViewControllerB *viewControllerB = [[ViewControllerB alloc] initWithNib:@"ViewControllerB" bundle:nil];
     viewControllerB.delegate = self;
     [[self navigationController] pushViewController:viewControllerB animated:YES];
  </code></pre>
  
  <p>Can you help me describe where this last portion of code goes?  I have tried and tried, and read the entire post many times and can't seem to figure this out without getting several errors.  Thanks for your help.</p>
  
  <p>Update:  I placed the code in viewDidLoad method in my ViewControllerB (child) equivalent, and received these errors::  </p>
  
  <ul>
  <li>No visible @interface for 'ViewControllerB' declares the selector
     'initWithNib:bundle:' </li>
  <li>Indexing expression is invalid because subscript type 'void' is not
     an integral or Objective-C pointer type</li>
  </ul>