I'm getting into loading web views and I don't have any problems, just a bit curious regarding "best-practices" for development.
From what I can tell there are 2 different ways to load HTML content and they both appear exactly the same in my view. One is through loadRequest which uses an
NSURLRequest and the other loads HTML from a base URL.
PHP Code:
NSString *path = [[NSBundle mainBundle] pathForResource:@"index" ofType:@"html" inDirectory:@"www"];
NSURL *baseURL = [NSURL fileURLWithPath:path];
NSURLRequest *request = [NSURLRequest requestWithURL:baseURL];
[webview loadRequest:request];
PHP Code:
NSString *path = [[NSBundle mainBundle] pathForResource:@"index" ofType:@"html" inDirectory:@"www"];
NSURL *baseURL = [NSURL fileURLWithPath:path];
NSError *error;
NSString *htmlstring = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:&error];
[webview loadHTMLString:htmlstring baseURL:baseURL];
Is there any specific benefit to using one method over the other? I tried googling and checking throughout the forums but I can't find any solid info comparing these 2 procedures. Right now I'm using loadRequest because it's neater in my code.
From what I can tell there is absolutely no difference in the final, compiled running application. Would love to hear input from others more knowledgable on the subject