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

readData(ofMinLength:maxLength:timeout:completionHandler:)

Asynchronously reads a number of bytes from the stream, and calls a handler upon completion. ストリームからあるバイト数を非同期に読み出します、そして完了に関してあるハンドラを呼び出します。

Declaration 宣言

func readData(ofMinLength minBytes: Int, 
    maxLength maxBytes: Int, 
      timeout: TimeInterval, 
completionHandler: @escaping (Data?, Bool, Error?) -> Void)

Parameters パラメータ

minBytes

The minimum number of bytes to read. 読み出す最小限のバイト数。

maxBytes

The maximum number of bytes to read. 読み出す最大限のバイト数。

timeout

A timeout for reading bytes. If the read is not completed within the specified interval, the read is canceled and the completionHandler is called with an error. Pass 0 to prevent a read from timing out. バイトを読み出すためのタイムアウト。読み出しがその指定された間隔内で完了されないならば、読み出しは取り消されます、そしてcompletionHandlerがあるエラーをつかって呼び出されます。0を渡すことで、読み出しが時間切れになるのを防いでください。

completionHandler

The completion handler to call when all bytes are read, or an error occurs. This handler is executed on the delegate queue. 全てのバイトが読み出される、またはエラーが発生する時に呼び出されることになる完了ハンドラ。このハンドラは、委任先キュー上で遂行されます。

This completion handler takes the following parameters: この完了ハンドラは、以下のパラメータを取ります:

data

The data read from the stream. ストリームから読み出すデータ。

atEOF

Whether or not the stream reached end-of-file (EOF), such that no more data can be read. ストリームがファイル終端(EOF)に達したかどうか、これ以上データが読み出されることができないことのような。

error

An error object that indicates why the read failed, or nil if the read was successful. あるエラーオブジェクト、それはなぜ読み出しが失敗したかを指し示します、またはnil、もし読み出しがうまくいったならば。

Discussion 議論

See Also 参照

Reading and Writing Data データの読み書き