Type Property

nullDevice

Returns a file handle associated with a null device.

Declaration

class var nullDevice: FileHandle { get }

Return Value

A file handle associated with a null device.

Discussion

You can use null-device file handles as “placeholders” for standard-device file handles or in collection objects to avoid exceptions and other errors resulting from messages being sent to invalid file handles. Read messages sent to a null-device file handle return an end-of-file indicator (an empty NSData object) rather than raise an exception. Write messages are no-ops, whereas fileDescriptor returns an illegal value. Other methods are no-ops or return “sensible” values.

When using this method to create a file handle object, the file handle owns its associated file descriptor and is responsible for closing it.

See Also

Getting a File Handle

init?(forReadingAtPath: String)

Returns a file handle initialized for reading the file, device, or named socket at the specified path.

init(forReadingFrom: URL)

Returns a file handle initialized for reading the file, device, or named socket at the specified URL.

init?(forWritingAtPath: String)

Returns a file handle initialized for writing to the file, device, or named socket at the specified path.

init(forWritingTo: URL)

Returns a file handle initialized for writing to the file, device, or named socket at the specified URL.

init?(forUpdatingAtPath: String)

Returns a file handle initialized for reading and writing to the file, device, or named socket at the specified path.

init(forUpdating: URL)

Returns a file handle initialized for reading and writing to the file, device, or named socket at the specified URL.

class var standardError: FileHandle

Returns the file handle associated with the standard error file.

class var standardInput: FileHandle

Returns the file handle associated with the standard input file.

class var standardOutput: FileHandle

Returns the file handle associated with the standard output file.