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