Saturday, April 27, 2013

NSFileHandle fileDescriptor example ios


fileDescriptor

Returns the file descriptor associated with the receiver.
- (int)fileDescriptor
Return Value of [NSFileHandle fileDescriptor]
The POSIX file descriptor associated with the receiver.
Discussion of [NSFileHandle fileDescriptor]
You can use this method to retrieve the file descriptor while it is open. If the file handle object owns the file descriptor, you must not close it yourself. However, you can use the closeFile method to close the file descriptor programmatically. If you do call the closeFile method, subsequent calls to this method raise an exception.
Example of [NSFileHandle fileDescriptor]

[handle offsetInFile];
    => off_t offset = lseek([handle fileDescriptor], 0, SEEK_CUR);

[handle seekToFileOffset:off];
    => off_t offset = lseek([handle fileDescriptor], off, SEEK_SET);