A stream that provides write-only stream functionality.
- iOS 2.0+
- macOS 10.3+
- tvOS 9.0+
- watchOS 2.0+
NSOutput is a concrete subclass of
NSStream that lets you write data to a stream. Although
NSOutput is probably sufficient for most situations requiring this capability, you can create a subclass of
NSOutput 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
NSOutput you may have to implement initializers for the type of stream data supported and suitably reimplement existing initializers. You must also provide complete implementations of the following methods:
From the current write pointer, take up to the number of bytes specified in the
maxparameter from the client-supplied buffer (first parameter) and put them onto the stream. The buffer must be of the size specified by the second parameter. To prepare for the next operation, offset the write pointer by the number of bytes written. Return a signed integer based on the outcome of the current operation:
If the write operation is successful, return the actual number of bytes put onto the stream.
If the stream is of a fixed length and has reached its capacity, return
If there was an error writing to the stream, return
YESif the stream can currently accept more data,
NOif it cannot. If you want to be semantically compatible with
YESif a write must be attempted to determine if space is available.