iosobjective-cuiwebviewnsurlprotocol

NSURLProtocol not responding to UIWebviews


I am having an issue with UIWebviews and a couple of custom NSURLProtocols that I have in my app.

All my non web view request are invoked with NSURLSession, so in order for those request to go through the protocols I need to set the setProtocolClasses array on my sessionconfig, at this point everything works as expected. For my web views, I do a registration on the didFinishLaunchingWithOptions: method in the AppDelegate with the [NSURLProtocol register class[MyProtocol Class]]. If i don't re-register before the execution of the web view request, that web view request won't go through the protocol.

Do you guys have any idea why I have to re-register to my custom protocol every time I try to load a web view request?


Solution

  • What is the request URL? Is it possible that there's another protocol class that gets registered after you? Does canInitWithRequest get called on your class at webview request time?