My aim is to build a web application using UIWebView on iOS, basicly doing what BlackBerry do for Webworks.
After reading around I'm left unsure about how cache worked so i tried the following test:
Created simple web application with "Hello World" to begin.
Build & Ran the application - Worked fine
Then changed the login.html (thats what my hello world was called) The changes i made was i reaplced hello world with a hyperlink to another page.
When i Build&Run again the old page is still display.
So im assuming there's caching somewhere?
Is there anyway to do the following/whats best?
- Disable caching as speed isnt important all our files are on disk?
- Clear the cache every time we launch the application?
Has anyone encountered this before?
Thanks
I have tried: How to delete the cache from UIWebview or dealloc UIWebview
Another update ------
Tried another simple test, i deleted my HTML folder with all the html,css,js files in it so its now in trash. Ran the application again and delete html references from the project and it still loads them all perfect. So the whole thing is cached somewhere.
As another try i have also added:
-(void)dealloc{
self.webView.delegate = nil;
self.webView = nil;
[webView release];
[super dealloc];
}
In NativeViewController.m this did not help.
My applications code:`
#import "NativeViewController.h"
@implementation NativeViewController
@synthesize webView;
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
[super viewDidLoad];
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"login" ofType:@"html"];
NSData *htmlData = [NSData dataWithContentsOfFile:filePath];
if (htmlData) {
NSBundle *bundle = [NSBundle mainBundle];
NSString *path = [bundle bundlePath];
NSString *fullPath = [NSBundle pathForResource:@"login" ofType:@"html" inDirectory:path];
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:fullPath]]];
}
}
- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
- (void)viewDidUnload {
[self.webView removeFromSuperview];
self.webView.delegate = nil;
self.webView = nil;
}
-(void)webViewDidFinishLoad{
[[NSURLCache sharedURLCahce] removeAllCachedResponses];
}
- (void)dealloc {
[webView release];
[super dealloc];
}
@end
`