3

I am loading a URL request in web View and sometimes I am getting the following warning in logs. Due to the warning, webViewDidFinishLoad never gets called.

WebKit discarded an uncaught exception in the webView:didFinishLoadForFrame: delegate: attempt to delete item 1 from section 0 which only contains 1 items before the update.

I have added web view in the collection view cell.

Any help would be highly appreciated!!

PinkeshGjr
  • 8,460
  • 5
  • 41
  • 56
User511
  • 1,456
  • 10
  • 28

3 Answers3

1

Add an exception breakpoint. This will fire when the exception is raised, which will let you see what's happening.

Debug>Breakpoints>Create Exception Breakpoint…

It is possible to encounter harmless caught exceptions that will fire this breakpoint, but they're very rare, so generally if this breakpoint fires, it's a legitimate problem. Don't confuse these exceptions with Swift throws. They're not related.

Rob Napier
  • 286,113
  • 34
  • 456
  • 610
  • It is only giving WebKit discarded an uncaught exception in the webView:didFinishLoadForFrame: delegate: But the app does not get crashed. – User511 Mar 06 '19 at 12:50
  • Understood, but does the Exception Breakpoint fire? Also, have you implemented the webView(_:didFinishLoadFor:) delegate method? This error suggest that there is a mistake there (not webViewDidFinishLoad) – Rob Napier Mar 06 '19 at 12:54
  • Yes, the Exception Breakpoint fire. Also webViewDidFinishLoad it is already added. – User511 Mar 06 '19 at 12:56
  • Great; if the exception breakpoint fired, you should be able to see what is generating it in the stacktrace. – Rob Napier Mar 06 '19 at 12:57
0

You should try following solution to fix you issue:

  1. In Info.plist file add a dictionary with key 'NSAppTransportSecurity'
  2. Add another element inside dictionary with key 'NSExceptionDomains'
  3. Add element with key 'YourDomainName.com' of type NSDictionary
  4. Add element with key 'NSIncludesSubdomains' of type Boolean and value set as YES
  5. Add element with key 'NSTemporaryExceptionAllowsInsecureHTTPLoads' of type Boolean and value set as YES

It will looks likes as follows:

Info.plist

I hope this will fix your issue.

Sagar Chauhan
  • 5,715
  • 2
  • 22
  • 56
0

Make sure you are setting the WebView’s delegate in the awakeFromNib call for the CollectionViewCell. How to detect when UIWebView starts loading when Webview is inside a Collection View cell?