I'm working with an app that makes extensive use of UIWebViews to display content loaded from the web. Most of the time this works well, but every once in a while (particularly on 3G) a connection problem will disrupt loading.
When it's the main webview, this isn't a problem because webView:didFailLoadWithError: is called on the delegate. However, the page HTML includes some and tags that reference other web resources, and very occasionally the initial request will go through but one of these subsequent requests will fail.
It seems like I ought to be able to trigger handling for these failures with an NSURLProtocol subclass, but in initWithRequest:cachedResponse:client:, I can't find a way of determining which UIWebView fired off the request (so that I can notify its delegate to display something to the user). Nor can I find a delegate method that gets called when one of these requests is fired (webView:shouldStartLoadWithRequest:navigationType: only gets called for window.location.href assignments and similar main document requests, not secondary requests). What's the simplest way to detect that one of those secondary requests has failed (and which URL it is trying to load, and which UIWebView is making it)?