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?


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?

链接地址: http://www.djcxy.com/p/34794.html

上一篇: 使用POST而不是GET将数据传递给目标c

下一篇: NSURLProtocol没有响应UIWebviews