Instance Method

write(_:maxLength:)

Writes the contents of a provided data buffer to the receiver.

Declaration

func write(_ buffer: UnsafePointer<UInt8>, maxLength len: Int) -> Int

Parameters

buffer

The data to write.

length

The length of the data buffer, in bytes.

Return Value

A number indicating the outcome of the operation:

  • A positive number indicates the number of bytes written.

  • 0 indicates that a fixed-length stream and has reached its capacity.

  • -1 means that the operation failed; more information about the error can be obtained with streamError.

See Also

Using Streams

var hasSpaceAvailable: Bool

A boolean value that indicates whether the receiver can be written to.