If I have some local HTML content that I need to load in a UIWebView, it seems like there are two ways to do it:
OR
Is one of these ways preferred over the other? Both seem to work.
On another note, if I do go with the first way, am I choosing the right String Encoding? I'm just loading a plain HTML file.
Code:
NSString *fileString = [[NSBundle mainBundle] pathForResource: SomeLocalHTMLFile ofType: @"html"];
NSString *newHTMLString = [[NSString alloc] initWithContentsOfFile: fileString encoding: NSASCIIStringEncoding error: NULL];
NSURL *newURL = [[NSURL alloc] initFileURLWithPath: fileString];
[myWebView loadHTMLString: newHTMLString baseURL: newURL];
OR
Code:
NSString *fileString = [[NSBundle mainBundle] pathForResource: SomeLocalHTMLFile ofType: @"html"];
NSURL *newURL = [[NSURL alloc] initFileURLWithPath: fileString];
NSURLRequest *newURLRequest = [[NSURLRequest alloc] initWithURL: newURL];
[myWebView loadRequest: newURLRequest];
Is one of these ways preferred over the other? Both seem to work.
On another note, if I do go with the first way, am I choosing the right String Encoding? I'm just loading a plain HTML file.