Initializer

init(protectionSpace:proposedCredential:previousFailureCount:failureResponse:error:sender:)

Initializes an authentication challenge from parameters you provide. 認証チャレンジをあなたが提供するパラメータから初期化します。

Declaration 宣言

init(protectionSpace space: URLProtectionSpace, 
proposedCredential credential: URLCredential?, 
previousFailureCount: Int, 
failureResponse response: URLResponse?, 
error: Error?, 
sender: URLAuthenticationChallengeSender)

Parameters パラメータ

space

The protection space for the authentication challenge. This provides additional information about the authentication request, such as the host, port, authentication realm, and so on. 認証チャレンジに対する保護空間。これは、追加情報を認証リクエストについて提供します、たとえば、ホスト、ポート、認証レルム、など。

credential

The proposed credential, or nil. 提案する資格情報、またはnil

previousFailureCount

The total number of previous failures for this request, including failures for other protection spaces. このリクエストに対する以前の失敗の総数、他の保護空間に対する失敗を含みます。

response

An instance of URLResponse containing the server response that caused you to generate an authentication challenge, or nil if no response object is applicable to the challenge. あなたに認証チャレンジを生成させたサーバ応答を含んでいるURLResponseのインスタンス、またはどんな応答オブジェクトもチャレンジに効力がないならばnil

error

An NSError instance describing the authentication failure, or nil if it is not applicable to the challenge. 認証失敗を記述しているNSErrorインスタンス、またはそれがチャレンジに効力がないならばnil

sender

The object that initiated the authentication challenge (typically, the object that called this method). 認証チャレンジを開始したオブジェクト(概して、このメソッドを呼び出したオブジェクト)。

Return Value 戻り値

A new authentication challenge object, with the given properties. 新しい認証チャレンジオブジェクト、その与えられたプロパティを持ちます。

Discussion 議論

Most apps don’t create URLAuthenticationChallenge instances themselves. Instead, they handle received challenges in the urlSession(_:task:didReceive:completionHandler:) method of URLSessionTaskDelegate. ほとんどのアプリは、URLAuthenticationChallengeインスタンスをそれ自身で作成しません。代わりに、それらは受け取ったチャレンジをURLSessionTaskDelegateurlSession(_:task:didReceive:completionHandler:)メソッドで取り扱います。

However, you might need to create authentication challenge objects when adding support for custom networking protocols, as part of your custom URLProtocol subclasses. しかしながら、あなたは認証チャレンジオブジェクトを作成する必要が、あつらえのネットワークプロトコルに対するサポートを追加している時にあるかもしれません、あなたのあつらえのURLProtocolサブクラスの一部として。

See Also 参照

Creating an Authentication Challenge Instance 認証チャレンジインスタンスを作成する