Mike Walker Mike Walker - 2 years ago 251
Swift Question

Swift open local HTML file with parameters

I have a local HTML file that I would like to load in a

, but would also like to pass a parameter inside. I can load the HTML file

webView.loadRequest(NSURLRequest(URL: NSBundle.mainBundle().URLForResource("apprules", withExtension: "html")!))

I would like to pass the local to the HTNL like
. Is there a way to do this in Swift?

Answer Source

Try this:

let url1 = NSBundle.mainBundle().URLForResource("apprules", withExtension: "html")!
let url2 = NSURL(string: "?lang=ja", relativeToURL: url1)!
webView.loadRequest(NSURLRequest(URL: url2))
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download