how I can enable caching in an UIWebView
?
It's frustrating. I'm looking for hours but no mentioned solutions in many other posts doesn't helped me.
I tried many solutions like https://stackoverflow.com/a/26174438, https://stackoverflow.com/a/1424301, http://codewithchris.com/tutorial-how-to-use-ios-nsurlconnection-by-example/, https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/URLLoadingSystem/Concepts/CachePolicies.html, iOS Cache a UIWebView, etc.
My code looks like
[self setUrl:[[NSString alloc] initWithFormat:@"http://example.com"]];
[[NSURLCache sharedURLCache] setDiskCapacity:0];
[[NSURLCache sharedURLCache] setMemoryCapacity:0];
[self setLoadUrl: [NSURL URLWithString:[self url]]];
[self setRequestObj:[NSURLRequest requestWithURL:[self loadUrl]]];
if caching
is disabled. If it's turned on I have
if([[self cache] isEqualToNumber:[[NSNumber alloc] initWithInt:1]])
{
[[NSURLCache sharedURLCache] setDiskCapacity:4 * 1024 * 1024];
[[NSURLCache sharedURLCache] setMemoryCapacity:32 * 1024 * 1024];
[self setRequestObj:[NSURLRequest requestWithURL:loadUrl cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0]];
}
How