fileHandleForReadingAtPath:
Returns a file handle initialized for reading the file, device, or named socket at the specified path.
+ (id)fileHandleForReadingAtPath:(NSString *)path
Parameters
- path
- The path to the file, device, or named socket to access.
Return Value of [NSFileHandle fileHandleForReadingAtPath]
The initialized file handle object or
nil
if no file exists at path.Discussion of [NSFileHandle fileHandleForReadingAtPath]
The file pointer is set to the beginning of the file. You cannot write data to the returned file handle object. Use the
readDataToEndOfFile
or readDataOfLength:
methods to read data from it.
When using this method to create a file handle object, the file handle owns its associated file descriptor and is responsible for closing it.
Example of [NSFileHandle fileHandleForReadingAtPath]
NSString *path = [[NSBundle mainBundle] pathForResource:@"nCode01"
ofType:@"txt"];
nCode = [NSFileHandle fileHandleForReadingAtPath:path];