The registration makes it available to NSURLConnection and the shared NSURLSession. If you don’t need that, it’s fine to skip the registration and just apply it to your session via `protocolClasses`. Share and Enjoy — Quinn “The Eskimo!” Apple Developer Relations, Developer Technical Support, Core OS/Hardware `let myEmail = "eskimo" + "1" + "@apple.com"`
One thing that is not clear to me is, and I would really appreciate some help here:
1. If I register a CustomNSURLProtocol using:
2. And if I start a new NSURLSession based on the defaultConfiguration like:
NSURLSessionConfiguration *sessionConfiguration = [NSURLSessionConfiguration defaultSessionConfiguration]; NSURLSession *session = [NSURLSession sessionWithConfiguration:sessionConfiguration delegate:nil delegateQueue:nil];
Those requests for that specific session will be intercepted by my CustomNSURLProtocol.
That's ok, make sense.
But what If I switch the order of the previous steps:
1. First create a NSURLSession based on the defaultSessionConfiguration and after that..
2. attempt to register my CustomNSURLProtocol
Will my requests be intercepted too?
Do the defaultSessionConfiguration have that protocol registered?
And how does registerClass: relates with the:
Is that even related?
OK, I have to ask, why does this matter?
I agree that the semantics in this space are not as well documented as they could be but the recommended steps are very clear:
If you want your protocol to be used by NSURLConnection and the shared NSURLSession, register it.
If you want your protocol to be used by a specific NSURLSession, add it to
Share and Enjoy
Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
let myEmail = "eskimo" + "1" + "@apple.com"