what's the consequence of registering the same NSURLProtocol more than once?

145 views Asked by At

I'm building a component that supports the enabling / disabling of a feature that requires an NSURLProtocol.

in the isEnabled setter I do:

- (void)setIsEnabled:(BOOL)isEnabled {
    _isEnabled = isEnabled;
    if (isEnabled) {
       [NSURLProtocol registerClass:[MyURLProtocol class]];
   } else {
       [NSURLProtocol unregisterClass:[MyURLProtocol class]];
   }
}

The URL loading system goes through the registered protocols in the order of registration, so I'm wondering what will be the consequence of registering the same protocol more than once as a result of this setter being fired multiple times? will it just get bumped to the top of the list ? or will this have further / other consequences ?

Other considerations:

  • I'm aware of the possibility to unregister every time before I register the protocol, but would like to avoid it if I can.
  • The component at hand is an SDK, not an app - so I can not register my protocol on application:didFinishLaunchingWithOptions...

Further to reading the documentation and the great hipsters notes, I couldn't find any relevant information, so any insight is appreciated !

0

There are 0 answers