When writing to file using OutputStream
, after that stream has been closed, there is no error, it silently fails to write.
Starting:
self.outputStream = OutputStream(toFileAtPath: filePath, append: true)
self.outputStream.delegate = self
self.outputStream.schedule(in: RunLoop.current, forMode: RunLoopMode.defaultRunLoopMode)
self.open()
Delegate is working:
func stream(_ aStream: Stream, handle eventCode: Stream.Event) {
//Will report that stream was opened.
... Writing some text - successful ...
self.outputStream.close()
self.outputStream.write(newData, maxLength: newData.count)
And.. nothing. No text is written, yet no error is reported.
Does writing to a closed stream not triggering an error? That is, should we check the stream status before writing?