0

The title says (quite) all: I would like to distribute an app with some HTML pages preloaded into the local Documents folder (they reflect the content of a mini mobile site available on the internet); then, when the contents of the pages are updated, the local HTML files into the app should be updated, so that the user can browse the updated informations also when not connected to the internet.

The app has to work since the first start, thanks to the preloaded pages, and then update itself periodically (I didn't need to check the modify date/time of the single files, it's enough to check and update them when the local copies are older than x days).

The problem: I think I can do it all, but I was asking to myself if is there some framework/class that does it automatically, because it sounds to be a pain :)

flip79
  • 1,178
  • 2
  • 15
  • 28

2 Answers2

1

Consider using ASIHTTPRequest. Check out this SO question.

Specifically, you might want to look into ASIWebPageRequest:

download complete webpages, including external resources like images and stylesheets. Pages of any size can be indefinitely cached, and displayed in a UIWebview / WebView even when you have no network connection.

I've also used AFNetworking for my own personal projects and it's made my life 10x easier. On the AFNetworking FAQ page, there's a question regarding caching mechanisms for offline viewing. It mentions that NSURLCache in iOS 5 introduced support for caching to disk for offline use - but only for http. If you need to cache https, consider using SDURLCache.

Here's a short additional resource in regards to network caching for iOS. Read the section titled iOS network caching

Community
  • 1
  • 1
Bio
  • 505
  • 4
  • 10
-1

If you are looking at pre popping your iOS app with the equivalent of a browser cache then https://github.com/rs/SDURLCache might be something to look into.

It hooks in with existing NSURLConnection frameworks such as AFNetworking and you just need to set the correct cache policy in your NSURLRequest.

Given its open source you should be able to figure out how where to place your data so it loads it without fetching from the server the first time then just specify when you want the cache to purge itself so it fetches it from the server?

Shaun
  • 412
  • 2
  • 7