I've subclassed NSURLProtocol
and registered it in didFinishLaunchingWithOptions
with this code:
+ (void) registerProtocol
{
static BOOL registered = NO;
if (!registered)
{
[NSURLProtocol registerClass:[MyURLProtocol class]];
registered = YES;
}
}
For the first UIWebView
in my app (in the mainwindow) the method canInitWithRequest
is triggered, and I can execute my custom code.
However I have a second UIWebView
, that is inside an UIViewController
which is pushed at some point in the app (presented modally). The canInitWithRequest
will NOT be called for the second UIWebView
, thus I cannot execute my custom code. This is even true when the protocol is registered after both instances of UIWebView
are created.
Anyone knows why?
[edit] d'oh! i just found it was just a plain error in the javascript that is loaded in the second webview :( works like a charm in both webviews now!