A stream that provides read-only stream functionality.
- iOS 2.0+
- macOS 10.3+
- tvOS 9.0+
- watchOS 2.0+
NSInput is an abstract superclass of a class cluster consisting of concrete subclasses of
NSStream that provide standard read-only access to stream data. Although
NSInput is probably sufficient for most situations requiring access to stream data, you can create a subclass of
NSInput if you want more specialized behavior (for example, you want to record statistics on the data in a stream).
Methods to Override
To create a subclass of
NSInput you may have to implement initializers for the type of stream data supported and suitably re-implement existing initializers. You must also provide complete implementations of the following methods:
From the current read index, take up to the number of bytes specified in the second parameter from the stream and place them in the client-supplied buffer (first parameter). The buffer must be of the size specified by the second parameter. Return the actual number of bytes placed in the buffer; if there is nothing left in the stream, return
0. Reset the index into the stream for the next read operation.
Return in 0(1) a pointer to the subclass-allocated buffer (first parameter). Return by reference in the second parameter the number of bytes actually put into the buffer. The buffer’s contents are valid only until the next stream operation. Return
NOif you cannot access data in the buffer; otherwise, return
YES. If this method is not appropriate for your type of stream, you may return
YESif there is more data to read in the stream,
NOif there is not. If you want to be semantically compatible with
YESif a read must be attempted to determine if bytes are available.