0

I would like to load a local html file from resources into a web view in a applescript objc app. I have added the files to the bundled resources but I'm not sure how to load them into the web view with something like

tell myWebView to setMainFrameURL_("file.html")

sorry for the trivial question, any help would be appreciated

waddle
  • 1

1 Answers1

0

To get this work you have to

  1. Add the WebKit.framework to the Linked Frameworks and Libraries section in your apps General Settings. Without this I ended up with the error cannot decode object of class (WebView)

  2. Create an Outlet. This is necessary to let your Applescript talk to UI elements.

    1. Write property myWebView : missing value in your AppDelegate.applescript and save it.
    2. Using the Interface Builder view connect (CTRL-drag) the App Delegate with your Web View and select myWebView.
    3. Now the property myWebView points directly to your Web View.
  3. Tell the WebView to load your HTML file from the app's resources folder:

    set appResourcesPosixPath to POSIX PATH of (path to current application as text) & "Contents/Resources/"
    tell myWebView to setMainFrameURL_(appResourcesPosixPath & "File.html")
    

Enjoy, Michael / Hamburg

ShooTerKo
  • 2,242
  • 1
  • 13
  • 18