I’m using the code below to load a text file content into a WebView but each time the method is called the content takes some time to load. Any idea of a caching policy I can use in this context to make it load faster ?
- (void)displayContent
{
@try {
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"about-us" ofType:@"txt"];
[web_view loadHTMLString:[NSString stringWithContentOfFile:filePath encoding:NSUTF8StringEncoding error:nil] baseURL:nil];
} @catch(NSException e) {
NSLog(@"%@",e);
}
}
Thx for helping,
Stephane
Why not just set a
fileContentsstring toniland ‘lazy instantiate’ it with the resource contents in your main bundle?For instance, your code could then be:
No reason to overcomplicate things unless you have other particular concerns.