title: UIWebView Delegate Confusion
body: <p>for the past couple of days I've been looking into UIWebViews and Delegates and I'm totally confused. I want to create a storyboard view controller which contains a web view. When a button is clicked in the web view I want to fire some code in the view controller as per the answer to this:</p>
  
  <p><a href="https://stackoverflow.com/questions/9826792/how-to-invoke-objective-c-method-from-javascript-and-send-back-data-to-javascrip">How to invoke Objective C method from Javascript and send back data to Javascript in iOS?</a></p>
  
  <p>However I'm confused as to how to set up my delegate (I'm confused as to what even a delegate is to be honest, is it the webview in relation to the viewcontroller?). I've been reading and watching some tutorials but I don't really understand the process and I don't think I'm doing it right. Here's what I have so far.</p>
  
  <p><strong>MyViewController.h</strong></p>
  
  <pre><code>#import &lt;UIKit/UIKit.h&gt;
  
  @protocol MyViewControllerDelegate;
  
  @interface MyViewController : UIViewController
  @property (nonatomic, weak) id&lt;MyViewControllerDelegate&gt; delegate;
  
  @property (strong, nonatomic) IBOutlet UIWebView *MyWebView;
  
  @end
  
  @protocol MyViewControllerDelegate &lt;NSObject&gt;
  
  -(bool)myWebView:(UIWebView*)myWebView
  shouldStartLoadWithRequest:(NSURLRequest*)request
                    navigationType:(UIWebViewNavigationType)navigationType;
  
  @end
  </code></pre>
  
  <p><strong>MyViewController.m</strong></p>
  
  <pre><code>#import "MyViewController.h"
  
  @interface MyViewController ()
  @end
  
  @implementation MyViewController
  
  - (void)viewDidLoad {
      [super viewDidLoad];
      [_MyWebView setDelegate:self];
  }
  
  - (void)didReceiveMemoryWarning {
      [super didReceiveMemoryWarning];
  }
  
  - (void)viewWillAppear:(BOOL)animated
  {   
  }
  
  @end
  </code></pre>
  
  <p>I'm not really sure where the implementation for:</p>
  
  <pre><code>-(bool)myWebView:(UIWebView*)myWebView
  shouldStartLoadWithRequest:(NSURLRequest*)request
                    navigationType:(UIWebViewNavigationType)navigationType;
  </code></pre>
  
  <p>should go.</p>
  
  <p>If anyone could help it would be greatly appreciated.</p>