An abstract class that handles the loading of protocol-specific URL data.
- iOS 2.0+
- macOS 10.2+
- tvOS 9.0+
- watchOS 2.0+
Don't instantiate an
NSURLProtocol subclass directly. Instead, create subclasses for any custom protocols or URL schemes that your app supports. When a download starts, the system creates the appropriate protocol object to handle the corresponding URL request. You define your protocol class and call the
register class method during your app’s launch time so that the system is aware of your protocol.
To support the customization of protocol-specific requests, define categories on
NSMutable with any custom API that you need. You can store and retrieve protocol-specific request data by using
NSURLProtocol’s class methods
NSURLResponse for each request your subclass processes successfully. You may want to create a custom, mutable
NSURLResponse class to provide protocol specific information.
When overriding methods of this class, be aware that methods that take a
task parameter are preferred by the system to those that do not. Therefore, you should override the task-based methods when subclassing, as follows: