Instance Method インスタンスメソッド

data(from:delegate:)

Retrieves the contents of a URL and delivers the data asynchronously.

Declaration 宣言

func data(from url: URL, delegate: URLSessionTaskDelegate? = nil) async throws -> (Data, URLResponse)

Parameters パラメータ

url

The URL to retrieve.

delegate

A delegate that receives life cycle and authentication challenge callbacks as the transfer progresses.

Return Value 戻り値

An asynchronously-delivered tuple that contains the URL contents as a Data instance, and a URLResponse.

Discussion 議論

Use this method to wait until the session finishes transferring data and receive it in a single Data instance. To process the bytes as the session receives them, use bytes(from:delegate:).

See Also 参照

Performing Asynchronous Transfers 非同期転送を実行する