A simple NSUrlCache that adds offline caching for iOS applications that use a UIWebView or similar
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src/NaiveIosUrlCache
.DS_Store all the things Sep 27, 2013
.gitignore all the things Sep 27, 2013
LICENSE
NaiveIosUrlCache.sln all the things Sep 27, 2013
NaiveIosUrlCache.userprefs all the things Sep 27, 2013
OfflineUrlCache.cs all the things Sep 27, 2013
README.md tweak readme Sep 27, 2013
Reachability.cs all the things Sep 27, 2013

README.md

Naive offline cache for iOS UIWebView applications

Dropping this in to an iOS application will allow UIWebView to work offline.

It doesn't include precaching (although that could be done by bundling cached files with the app) or any smarts around cache invalidation or caching while online. In fact if the device is online it will always use the online resource and update the cached item. The only thing it adds is offline capability.

The cache is assigned to the static NSUrlCache.SharedCache so add this to your AppDelegate.FinishedLaunching or similar:

var cachePath = Path.Combine(Environment.GetFolderPath (Environment.SpecialFolder.MyDocuments), "urlcache");
NSUrlCache.SharedCache = new OfflineUrlCache(cachePath);

This will only affect anything that uses NSUrl such as UIWebView. So anything that is in .NET world like RestSharp won't be affected. Which is usually what you would want.

It uses Dan Clarke's Monotouch port of [Tony Million's Reachability](https://github.com/tonymillion/Reachability class). Originally this started as a port of Edwin Vermeer's EVURLCache which has a lot more features, but I ended up cutting out just about everything.