readDataToEndOfFile
Synchronously reads the available data up to the end of file or maximum number of bytes.
- (NSData *)readDataToEndOfFile
Return Value of [NSFileHandle readDataToEndOfFile]
The data available through the receiver up to maximum size that can be represented by an
NSData
object or, if a communications channel, until an end-of-file indicator is returned.Discussion of [NSFileHandle readDataToEndOfFile]
This method invokes
readDataOfLength:
as part of its implementation.
Example of [NSFileHandle readDataToEndOfFile]
-(NSString *) readToEnd
{
if (currentOffset >= totalFileLength) { return nil; }
[fileHandle seekToFileOffset:currentOffset];
NSData *data = [fileHandle readDataToEndOfFile];
currentOffset = totalFileLength;
[fileHandle seekToEndOfFile];
return [[[NSString alloc] initWithData:data encoding:encoding] autorelease];
}