3

I need to download an entire webPage and store it in app's documents directory and load it from the cache the next time user visits.

No matter how much I search, I always end up with ASIWebPageRequest..!! even though, it works, its very old and deprecated.So I am looking for some alternatives. Another reason I am trying to avoid it is because ....

It is a completely reimplemented URL loading system, based on very low level constructs (CFNetwork). So as Apple makes improvements to their high level libraries (NSURLConnection, NSCache) ASIHTTP doesn't get those advancements.

Hence, I tried this sample code from apple, It gives me a NSData of whichever url i feed it. but, when I try to load this NSData into UIWebView using, loadData:MIMEType:textEncodingName:baseURL: method, I need to specify the mimetype as "text/html" , now the images and links in the webpage doesn't load..!

Is there any other way I can use to achieve it..? perhaps using NSURLCache..? but how?? Is there any other good libraries ou there that i can use or am I stuck with ASIWebPageRequest..?

FYI, I need to download the entire webpage with all js, css etc.

akshaynhegde
  • 1,938
  • 3
  • 17
  • 36
  • You can use this.. http://stackoverflow.com/questions/1162295/library-for-caching-web-pages-on-iphone – Ahmed Z. May 22 '13 at 04:36
  • 1
    THis is another tutorial with your problem's solution http://www.cocoawithlove.com/2010/09/substituting-local-data-for-remote.html – Ahmed Z. May 22 '13 at 04:37
  • 2
    @AhmedZ. Since iOS 5 , `NSURLCache` could store cached content on file system for `http`. The article you linked is a workaround for iOS 4 or lower. – Bob Cromwell May 22 '13 at 06:41
  • @BobCromwell .. thanks for identifying that.. – Ahmed Z. May 22 '13 at 07:11
  • I referred to EVURLCache (https://github.com/evermeer/EVURLCache) and a nice article here http://nshipster.com/nsurlcache/... with some little tweaks, I am able to achieve it..! @Bob Cromwell , thank you for suggesting NSURLCacheStoragePolicy and NSURLCache. – akshaynhegde May 22 '13 at 08:10

1 Answers1

-1

About an alternative of ASI, AFNetworking is much more popular now. If you want to cache your content, you should have a look at NSURLCacheStoragePolicy and NSURLCache.

Bob Cromwell
  • 445
  • 2
  • 14