Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6135649
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:30:17+00:00 2026-05-23T17:30:17+00:00

I am trying to archive my UIWebView object using NSKeyedArchiver and restore it later

  • 0

I am trying to archive my UIWebView object using NSKeyedArchiver and restore it later using NSKeyedUnarchiver in the same state. Archiving/Unarchiving works, but the UIWebView 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.

I’ve tried saving the HTTPBody of the NSURLRequest of the UIWebView, but that always returns (null), so I think I am barking up the wrong tree there. (or I am fetching it wrong?)

Here’s what I have tried:

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"];

What am I missing here? I need to retain the UIWebView as it was and load it again in the same state without having to open the URL at a later stage.

And yes, I am aware of document.documentElement.outerHTML and document.documentElement.innerHTML, but that’s not what I am looking for. I need to retain the whole website for later, not just the HTML code.

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T17:30:18+00:00Added an answer on May 23, 2026 at 5:30 pm

    You’re trying to do something that NSKeyedArchiver just won’t do. Sorry! If you want to archive a web page you have to do it yourself and then reload the page when you recreate the web view.

    To get the websites data you need to do the loading yourself (using NSURLConnection etc) and store it as it arrives.

    I’d take a look at the ASIHTTP library – it replaces NSURL… methods with (IMHO) a much nicer and more flexible set of objects. They’ve just added a new method that should do exactly what you’re trying to do – it’s called ASIWebPageRequest.

    Hope that helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to archive, unarchive objects using NSKeyedArchiver, NSKeyedUnarchiver, NSCoding (initWithCoder, encodeWithCoder methods)
I was trying to archive an object into a plist file and load it
I'm trying to build a sfx (self extracting archive) using winrar. I'm using VS2008
what i am trying to archive here is to traverse within controls using the
While trying to zip an archive using the java.util.zip I ran into a lot
I am trying to Compress and Archive all the files in a folder, using
I'm trying to use Archive::Zip to zip a directory but the resulting zip I
am trying to add a file to an existing archive using the following code.
I am using Xcode 4.1 and MacOSX Lion 10.7. I am trying to archive
I am trying to use --whole-archive option, but it seems to not work with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.