Type Method 型メソッド

registerClass(_:)

Attempts to register a subclass of URLProtocol, making it visible to the URL loading system. URLProtocolのサブクラスの登録を試みます、それがURLローディングシステムに見えるようにします。

Declaration 宣言

class func registerClass(_ protocolClass: AnyClass) -> Bool

Parameters パラメータ

protocolClass

The subclass to register. 登録することになるサブクラス。

Return Value 戻り値

true if the registration is successful, false otherwise. The only failure condition is if protocolClass is not a subclass of URLProtocol. true、もし登録がうまくいくならば、そうでなければfalse。唯一の失敗条件は、protocolClassURLProtocolの下位クラスでない場合です。

Discussion 議論

Register any custom URLProtocol subclasses prior to making URL requests. When the URL loading system begins to load a request, it tries to initialize each registered protocol class with the specified request. The first URLProtocol subclass to return true when sent a canInit(with:) message is used to load the request. There is no guarantee that all registered protocol classes will be consulted. すべてのあつらえのURLProtocolサブクラスをURLリクエストをする前に登録してください。URLローディングシステムがあるリクエストのロードを開始する時、それは各登録されたプロトコルクラスをその指定のリクエストで初期化しようと試みます。まずcanInit(with:)メッセージを送信した時にtrueを返すURLProtocolサブクラスがそのリクエストをロードするために使われます。全ての登録されたプロトコルクラスが考慮に入れられる保証はありません。

Classes are consulted in the reverse order of their registration. A similar design governs the process to create the canonical form of a request with canonicalRequest(for:). クラスは、それら登録の受け取り順で考慮に入れられます。同様の設計は、リクエストの正準形式をcanonicalRequest(for:)で作成する過程を左右します。

See Also 参照

Registering and Unregistering Protocol Classes プロトコルクラスの登録および登録解除