Creates an authentication challenge from an existing challenge instance.
- iOS 2.0+
- macOS 10.2+
- Mac Catalyst 13.0+Beta
- tvOS 9.0+
- watchOS 2.0+
The challenge that you want to copy. Usually, this is a challenge received by an existing
NSURLProtocolsubclass that you are subclassing.
The sender that you want to use for the new object. Typically, the sender is the instance of your custom
NSURLProtocolsubclass that called this method.
A new authentication challenge object, based on an existing challenge.
Most apps don’t create
NSURLAuthentication instances themselves. Instead, they handle received challenges in the
URLSession: method of
However, you might need to create authentication challenge objects when adding support for custom networking protocols, as part of a custom
NSURLProtocol subclass. When you subclass an existing
NSURLProtocol subclass, this initializer lets you modify challenges issued by the existing class so that your subclass receives any responses to those challenges.