I was wondering what code I could use instead of initWithContentsOfFile: since I was looking for something that is not deprecated but cannot find anything. I am trying to display a local HTML file in a webview, below is the code:
- (void)viewDidLoad { [super viewDidLoad]; NSString *htmlPath = [[NSBundle mainBundle] pathForResource:@"index" ofType:@"html"]; NSURL *bundleUrl = [NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]]; NSString *html = [[NSString alloc] initWithContentsOfFile:htmlPath]; [self.myWebView loadHTMLString:html baseURL:bundleUrl]; }
And I get a warning that initWithContentsOfFile: is deprecated and would like to know how to update it.
iphone cocoa-touch webview
user437038
source share