Shri
Shri

Reputation: 2139

How to Save Web Pages and Blogs for Offline Reading in iPhone

I need to save the contents of blogs loaded on the webview for offline reading. Does webview support caching and if it does, how much is the size it can cache? Currently I am loading the webview as follows:

NSURL *url = [NSURL URLWithString:_entry.articleUrl];    
_webView.delegate =self;
[_webView loadRequest:[NSURLRequest requestWithURL:url]];

I get the resposnse in

- (void)webViewDidFinishLoad:(UIWebView *)webView

but could not find anywhere in UIWebView's documentation where I can find the data loaded in that webView. Any help will be greatly appreciated.

Upvotes: 0

Views: 395

Answers (1)

user994299
user994299

Reputation:

    NSData *cacheUrlData = [NSData dataWithContentsOfURL:url];

Save this NSData anywhere you want. Preferably in dictionary with the key=url and value= cacheUrlData and write this dictionary to a plist file in Documents Directory..

Upvotes: 2

Related Questions