I am communicating over 'http://' and 'https://'. When and why to use NSURLProtocol?
I read that it is used for new/custom schemes and for the above schemes we do not need to use NSURLProtocol.
I am communicating over 'http://' and 'https://'. When and why to use NSURLProtocol?
I read that it is used for new/custom schemes and for the above schemes we do not need to use NSURLProtocol.
How it can be useful?
It is a part of the URL loading mechanism in iOS, you have the power to change the way requests are handled at a global level. This will allow you to register your NSURLProtocol subclass with the system and have it work for all connections initiated by your application, even if those connections are created and started beyond your control. This can be a life saver in some situations. Source: Tutorial
Well, suppose you want all of your app requests to have a certain header in them, or that you want to intercept some requests before they are sent, or that you want to have a more elaborate cache system than the one that is provided to you by the frameworks within the SDK. By extending NSURLProtocol, you open up a multitude of possibilities to improve your app.
Source: Blog
You use NSURLProtocol if you want data that doesn't come from the Internet to appear in a browser.