Instance Method

readDataOfMinLength:maxLength:timeout:completionHandler:

Asynchronously reads a number of bytes from the stream, and calls a handler upon completion.

Declaration

- (void)readDataOfMinLength:(NSUInteger)minBytes maxLength:(NSUInteger)maxBytes timeout:(NSTimeInterval)timeout completionHandler:(void (^)(NSData *data, BOOL atEOF, NSError *error))completionHandler;

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

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.

error

An error object that indicates why the read failed, or nil if the read was successful.

See Also

Reading and Writing Data

- writeData:timeout:completionHandler:

Asynchronously writes the specified data to the stream, and calls a handler upon completion.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software