IOS 8 UIWebview Delegate: WebKit threw an uncaught exception in webView: didFinishLoadForFrame:

Sometimes my application works fine, but sometimes it fails with this error:

* WebKit has thrown an uncaught exception in webView: didFinishLoadForFrame: delegate: * - [__ NSArrayM objectAtIndex:]: index 6 is out of bounds [0 .. 5]

I found several other Exception Questions in WebKit, but none with NSRangeException.

My code is:

- (id) init {
   myWebView = [[UIWebView alloc] init];
   myWebView.delegate = self;
   [myWebView stopLoading];
   return self;
}

- (void)loadUrl:(NSString *)urlAddress  {

    NSURL *url = [NSURL URLWithString:urlAddress];
    NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
   [myWebView stopLoading];
   [myWebView loadRequest:requestObj];

}

 - (void)webViewDidFinishLoad:(UIWebView *)webView{

    if (!myWebView.isLoading) {
        [myWebView stopLoading];
        if (selectedInfo == LOADTable) {

            NSString *html = [NSString stringWithFormat:@"%@",[myWebView stringByEvaluatingJavaScriptFromString:@"document.body.innerHTML"]];
            [myWebView stopLoading];
            [self parseTable:html];

        } 

    }
 }

Does anyone have an idea how to solve this error.

UIWebViewnot displayed on any UIView. Just for loading HTML.

+4
source share
2 answers

parseTable:. , parseTable: , html. parseTable:, , , NSArray objectAtIndex: . , 7- ( 6) NSArray, 6 ( 5).

+2

, [self parseTable: html]; . ,

+2

Source: https://habr.com/ru/post/1607144/


All Articles