Initializer

init(forUpdating:)

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

Declaration

convenience init(forUpdating url: URL) throws

Parameters

url

The URL of the file, device, or named socket to access.

error

If an error occurs, upon return contains an NSError object that describes the problem. Pass NULL if you do not want error information.

Return Value

The initialized file handle object or nil if no file exists at url.

Discussion

The file pointer is set to the beginning of the file. The returned object responds to both NSFileHandleread... messages and write(_:).

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.

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.

class var nullDevice: FileHandle

Returns a file handle associated with a null device.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software