title: Cocoa WebView - Loading a local HTML page
body: <p>After browsing quite a bit, I still can't figure this out. I've added a HTML page and its images directory into my project Resources group in Xcode (Copied them over).</p>
  
  <p>When I try to load the WebView with the following code, the text is displayed fine, but the images aren't loaded.</p>
  
  <pre><code>NSString *path = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"index.html"];
  NSString *htmlContent = [NSString stringWithContentsOfFile:path];
  NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]];
  [[tempWebView mainFrame] loadHTMLString:htmlContent baseURL:url];
  </code></pre>
  
  <p>EDIT: Sorry about the delay, here's some basic html that failed.</p>
  
  <pre><code>&lt;html&gt;
      &lt;body&gt; 
          &lt;img src="images/bg.png"&gt;&lt;/img&gt; 
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>And my edited code looks like this -</p>
  
  <pre><code>NSString *path = [[NSBundle mainBundle] pathForResource:@"index" ofType:@"html"];
  NSURL *url = [NSURL fileURLWithPath:path];
  [[webView1 mainFrame] loadRequest:[NSURLRequest requestWithURL:url]];
  </code></pre>
  
  <p>EDIT2: Just realized it was an issue with the path. Apparently <code>&lt;img src = "images/bg.png"&gt;</code> doesn't work, but if I copy bg.png to the root directory and say <code>&lt;img src = "bg.png"&gt;</code> everything works fine. I'm still not sure where I'm going wrong with this.</p>