title: OSX Swift webview load local file
body: <p>I know this has been asked many times and I have read <a href="https://stackoverflow.com/questions/18716221/ios-uiwebview-load-local-device-html-file-path?lq=1">quite</a> <a href="https://stackoverflow.com/questions/7283654/webview-load-html-page-with-all-resources-from-a-local-directory">a</a> <a href="https://stackoverflow.com/questions/7063276/how-to-load-local-html-file-into-uiwebview">few</a> <a href="https://stackoverflow.com/questions/1959243/nsurlconnection-nsurlrequest-proxy-for-asynchronous-web-service-calls">questions</a>
  and googled for days with no success so far. </p>
  
  <p>I just want to load a local html file in a desktop app, truth is for this project I need a JS library and most of it is already done as a webpage (css, js and html, no server side processing needed). I dont want to force the app to load the webpage from an internet server so as to not force the users to have an internet connection. Needless to say I am completely inexperienced in Swift and apple development.</p>
  
  <p>Right now this is the problem I am having:
  <img src="https://i.stack.imgur.com/AENIO.gif" alt="enter image description here">
  the ide complaints about the params and I cant seem to get them right.</p>
  
  <p>For reference here is a snippet of my latest code:</p>
  
  <pre><code>class AppDelegate: NSObject, NSApplicationDelegate
  {
      @IBOutlet weak var window: NSWindow!
      @IBOutlet weak var webView: WebView!
      typealias NSSize = CGSize
  
      func applicationDidFinishLaunching(aNotification: NSNotification?)
      {
          self.window.title = "Chess Study Room"
  
          var try1 = "main.html";
          println(try1);
  
          var try2 = NSURL(string: try1)!;
          println(try2);
  
          var try3 =
          NSBundle.URLForResource("main", withExtension: "html", subdirectory: "web", inBundleWithURL: try2);
          println(try3);
  
          var try4 = NSBundle.pathForResource("main", ofType: "html", inDirectory: "web");
          println(try4);
  
          var try5 = NSString.stringByAppendingPathComponent("main.html");
          println(try5);
          // var myInternalUrl = NSURL(string: myInternalHtml)!;
          //NSLog("%s", myInternalHtml!);
          var request = NSURLRequest(try1,
              NSURLRequestCachePolicy.ReloadIgnoringLocalAndRemoteCacheData,
              60
          );
  
          self.webView.frameLoadDelegate = self;
          self.webView.mainFrame.loadRequest(
              request!
          );
      }
  </code></pre>
  
  <p>But as you can see from my gif I've tried other things as well. The full errors are <code>/path/TestWebView/AppDelegate.swift:32:35: Extra argument in call</code> and <code>/path/TestWebView/AppDelegate.swift:32:36: Missing argument for parameter 'cachePolicy' in call</code></p>
  
  <p>At this point try1 and try2 output "main.html", try3 and try4 output nil and try5 outputs"(Function)"</p>
  
  <p>The structure of folders is this:
  <img src="https://i.stack.imgur.com/wMPuS.png" alt="enter image description here"></p>
  
  <p>I added the folder "web" as a reference (as advised in another question) but I doubt this would work to ship just one package...</p>
  
  <p>I dont know if there's any difference but I'm not targetting iOS, I want this to be a desktop app.</p>
  
  <p>Any advise will be greatly appreciated</p>