Note that there are some explanatory texts on larger screens.

plurals
  1. POUIWebView Archiving - iPhone
    text
    copied!<p>I am trying to archive my <code>UIWebView</code> object using <code>NSKeyedArchiver</code> and restore it later using <code>NSKeyedUnarchiver</code> in the same state. Archiving/Unarchiving works, but the <code>UIWebView</code> is blank when unarchived again (I archived it with a website loaded), but I need it to have the same website it did before I archived it. </p> <p>I've tried saving the <code>HTTPBody</code> of the <code>NSURLRequest</code> of the <code>UIWebView</code>, but that always returns <code>(null)</code>, so I think I am barking up the wrong tree there. (or I am fetching it wrong?)</p> <p>Here's what I have tried:</p> <pre><code>UIWebView*currentWebview = [[Controller sharedInstance] mainWebView]; NSData*webViewData = [NSKeyedArchiver archivedDataWithRootObject:currentWebview]; [sub setObject:webViewData forKey:@"Instance"]; //saves and decodes correctly, but that's a blank `UIWebView` even though I saved it with contents being loaded NSData*body = [[currentWebview request] HTTPBody]; //returns (null) always, but the webview is not null and has a valid request [sub setObject:body forKey:@"HTTP_Body"]; </code></pre> <p>What am I missing here? I need to retain the <code>UIWebView</code> as it was and load it again in the same state without having to open the URL at a later stage.</p> <p>And yes, I am aware of <code>document.documentElement.outerHTML</code> and <code>document.documentElement.innerHTML</code>, but that's <strong>not</strong> what I am looking for. I need to retain the whole website for later, not just the HTML code.</p> <p>Thanks!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload