Schedules an asynchronous read operation on the specified channel.
- iOS 5.0+
- macOS 10.7+
- Mac Catalyst 13.0+Beta
- tvOS 9.0+
- watchOS 2.0+
The channel to use when reading the data.
For random-access channels, this parameter specifies the offset into the channel from which to read. The offset is specified relative to the initial file pointer of the channel’s file descriptor at the time the channel was created.
For stream-based channels, this parameter is ignored and data is read from the current position.
The number of bytes to read from the channel. Specify
SIZEto continue reading data until an EOF is reached.
The dispatch queue on which to submit the
The block to use to process the data read from the channel. This block may be queued multiple times to process a given data request. Each time the block is queued, the
dataparameter passed to the handler contains the most recently read chunk of data. The handler has no return value and takes the following parameters:
A Boolean value indicating whether the operation is complete.
dispatchobject containing the data read from the file descriptor.
errnocondition if there was an error; otherwise, the value is
Your block need not be reentrant. The system guarantees that only one instance of this block will be executed at any given time.
This function reads the specified data and submits the handler block to queue to process the data. If the
done parameter of the handler is set to false, it means that only part of the data was read. If the
done parameter is
YES, it means the read operation is complete and the handler will not be submitted again. If an unrecoverable error occurs on the channel’s file descriptor, the
done parameter is set to true and an appropriate error value is reported in the handler’s error parameter.
If the handler is submitted with the done parameter set to true, an empty data object, and an error code of 0, it means that the channel reached the end of the file.