Instance Method

initWithFileDescriptor:closeOnDealloc:

Initializes and returns a file handle object associated with the specified file descriptor and deallocation policy.

Declaration

- (instancetype)initWithFileDescriptor:(int)fd closeOnDealloc:(BOOL)closeopt;

Parameters

fileDescriptor

The POSIX file descriptor with which to initialize the file handle.

flag

YES if the returned file handle object should take ownership of the file descriptor and close it for you or NO if you want to maintain ownership of the file descriptor.

Return Value

An initialized file handle object.

Discussion

If flag is NO, the file descriptor you pass in to this method is not owned by the file handle object. In such a case, you are responsible for closing the file descriptor at some point after disposing of the file handle object. If you want the file handle object to close the descriptor for you automatically, pass YES for the flag parameter.

See Also

Creating a File Handle

- initWithFileDescriptor:

Initializes and returns a file handle object associated with the specified file descriptor.