ios - Custom NSURLProtocol added to configuration.protocolClasses prevents working of default url protocols -


i try add custom nsurlprotocol nsurlsession in order serve test data calls, while providing normal internet connectivity other calls. need adding nsurlprotocol session configuration's protocolclasses, session resides in library included in project.

for reason setup deliver test data right when custom protocol takes request returning true caninitwithrequest call, other requests (when returns false) default protocols still in protocolclasses behind custom protocol request , return true on caninitwithrequest call, but never send request internet , deliver request timeout after 30 seconds instead. when remove custom protocol protocolclasses, works fine - test data not served anymore, of course.

this code use installing protocol:

    nsurlsessionconfiguration* sessionconfiguration = [nsurlsessionconfiguration ephemeralsessionconfiguration];     nsmutablearray* protocols = [nsmutablearray arraywitharray:sessionconfiguration.protocolclasses];     [protocols insertobject:[myprotocol class] atindex:0];     sessionconfiguration.protocolclasses = protocols;     mysession = [nsurlsession sessionwithconfiguration:sessionconfiguration]; 

when register custom protocol [nsurlprotocol registerclass:[myprotocol class]], fallthrough work, written can't use approach in project.

any idea on why not working correctly?

firstly there misprint in code snippet, should protocols instead of array variable. ))

i think in case of custom protocol, makes sense see protocol client , on( propertyfokey: inrequest:) method startloading(or stoploading) called?

ah, have re read question.

in case of [nsurlprotocol registerclass] , custom class, if being latest registered, handle url scheme. in case seems there another(void) protocol handles request.


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -