In iOS, I'd like to be able to associate an NSURLRequest
--any NSURLRequest
, whether a navigation request or image or stylesheet request--with the UIWebView
that sent it. This seems to call for the implementation of an NSURLProtocol
subclass to capture and analyze requests as they come through. However, I can't find a way to correlate a request with its web view, and NSURLProtocol
only seems to understand NSURLRequest
s.
This would be fine for navigation requests, as I could make the association in my UIWebViewDelegate
. But this won't work for secondary resource requests such as images, which do not trigger UIWebViewDelegate
methods.
Anyone have any thoughts as to the best way to make this association?
If I understand your question correctly, you could just do
NSURL *url = [[webView request] URL];