How to get Swift to interact with a Webview?
<p>I'm building a basic iOS app with Xcode that mainly just contains a webview with my web app inside.</p>

<p>I was wondering if there was a decent way to save the users username to the devices storage when logging in so that it can be automatically entered when opening the app next time. Since the app is a webview, I don't believe there is a way to keep the user logged in (like other major apps do, such as Facebook), so I think that auto filling the username will be beneficial for them.</p>

<p>I found <a href="https://stackoverflow.com/questions/4772341/is-it-possible-for-a-uiwebview-to-save-and-autofill-previously-entered-form-valu">this question and answer</a> that could possibly solve my problem, although it's in good ol' Objective C.</p>

<p>My current attempt, that does absolutely nothing:</p>

<pre><code>let savedUsername = "testusername"

let loadUsernameJS = "document.getElementById(\"mainLoginUsername\").value = " + savedUsername + ";"

self.Webview.stringByEvaluatingJavaScriptFromString(loadUsernameJS)
</code></pre>

<p>Is this a possibility with Swift?</p>