title: iOS Master-Detail app: defining protocol, delegates
body: <p>In the master-detail application template (using ARC, storyboards) in XCode 4.3.2, I am trying to change (more specifically replace) the detail view when an item in master table view is selected. I am trying to implement delegates/protocols for this.</p>
  
  <p><strong>What I am confused about is - which class should implement the methods defined in protocol - master or detail?</strong> </p>
  
  <p>Having the detail view implement the protocol method makes sense to me since, I'll be push/popping the view controllers in detail view based on the selection (passed as a string from master via the protocol method).</p>
  
  <p>Here's what I tried</p>
  
  <p>1) Defined the protocol in MasterViewController.h</p>
  
  <pre><code>@protocol MasterViewDelegate &lt;NSObject&gt;
  - (void)masterSelectionChanged:(NSString *)selection;
  @end
  @interface MasterViewController:UIViewContoller
  @property (nonatomic, weak) id &lt;MasterViewDelegate&gt; delegate
  </code></pre>
  
  <p>2) in MasterViewController.m</p>
  
  <pre><code>@synthesize delegate;
  - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  {
      [delegate masterSelectionChanged:@"Some string based on indexPath.row"];
  }
  </code></pre>
  
  <p>3) in DetailViewController.h</p>
  
  <pre><code>#import "MasterViewController.m"
  @interface DetailViewController:UINavigationController &lt;MasterViewDelegate&gt;
  @end
  </code></pre>
  
  <p>4) in DetailViewController.m</p>
  
  <pre><code>#pragma mark - MasterViewDelegate
  - (void)masterSelectionChanged:(NSString *)selection
  {
      NSLog(@"the selection is: %s", selection);
      // WIll push/pop view over here, may be perform segues based on selection
  }
  </code></pre>
  
  <p>In this process, upon selecting the rows in master table, nothing happened. No crash, no display of log, no error while building either. What did I miss over here? </p>