Instance Method

write(_:)

Synchronously writes the specified data to the receiver.

Declaration

func write(_ data: Data)

Parameters

data

The data to be written.

Discussion

If the receiver is a file, writing takes place at the file pointer’s current position. After it writes the data, the method advances the file pointer by the number of bytes written. This method raises an exception if the file descriptor is closed or is not valid, if the receiver represents an unconnected pipe or socket endpoint, if no free space is left on the file system, or if any other writing error occurs.

See Also