If there's some way to get your original NSURL
used as mainDocumentURL
that would be ideal. If there's no way to prevent it being copied, I thought of the following hack as an alternative:
Before the creation of each UIWebView
, set the user agent string to a unique value. Supposedly this change only affects UIWebView
objects that are created subsequently, so each view will end up with its own distinctive user agent string.
In the NSURLProtocol
implementation, you can check the user agent string to identify the associated UIWebView
and pass it through to the real protocol handler using the actual user agent string (so the server will see nothing different).
All this depends on the views really ending up with different UA strings. Let me know if you manage to get it to work!