I am trying to run the following code in my app (ref: iPhone Dev: UIWebView baseUrl to resources in Documents folder not App bundle)
NSString *imagePath = [[NSBundle mainBundle] resourcePath];
imagePath = [imagePath stringByReplacingOccurrencesOfString:@"/" withString:@"//"];
imagePath = [imagePath stringByReplacingOccurrencesOfString:@" " withString:@"%20"];
NSString *HTMLData = @"<h1>Hello this is a test</h1><img src="sample.jpg" alt="" width="100" height="100" />";
[webView loadHTMLString:HTMLData baseURL:
[NSURL URLWithString:
[NSString stringWithFormat:@"file:/%@//",imagePath]
]];
It works perfectly well in a separate project. But when I try it in my existing project, I get the following on the console, followed b a blank webView :
*** WebKit discarded an uncaught exception in the webView:decidePolicyForNavigationAction:request:frame:decisionListener: delegate: <NSRangeException> *** -[__NSArrayI objectAtIndex:]: index 1 beyond bounds [0 .. 0]
Any ideas on where shall I look for. in my code?