I have an iPhone app that shows a website. This website changes it's content from time to time but my app doesn't reload it every time it is opened. I tried to prevent the caching of the site, but without success.
This is my init method:
- (id)init:(NSString *)url withTitle:(NSString *)theTitle withPageName:(NSString *)pageName {
self = [super init];
if(self) {
NSLog(@"websiteviewcontroller init");
self.title = theTitle;
self.url = url;
self.pageName = pageName;
CGRect frame = [[UIScreen mainScreen] applicationFrame];
webView = [[UIWebView alloc] initWithFrame:frame];
NSURL *theURL = [NSURL URLWithString:url];
[webView loadRequest:[NSURLRequest requestWithURL:theURL]];
// support zooming
webView.scalesPageToFit = YES;
//[[NSURLCache sharedURLCache] removeAllCachedResponses];
[webView reload];
}
return self;
}
This is my viewWillAppear-Method:
- (void)viewWillAppear:(BOOL)animated {
CGRect frame = [[UIScreen mainScreen] applicationFrame];
webView = [[UIWebView alloc] initWithFrame:frame];
NSURL *theURL = [NSURL URLWithString:url];
[webView loadRequest:[NSURLRequest requestWithURL:theURL]];
[webView reload];
// support zooming
webView.scalesPageToFit = YES;
}
Please help me to solve this problem. All answers are much appreciated.
This code snipplet fixed my problem:
[[NSURLCache sharedURLCache] removeAllCachedResponses];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With