Name

NSFileHandle — Mac OS X 10.0

Synopsis

This class is used to read and write data to and from an open file or open communications channel, such as a networking socket. The class provides methods for working with files, and contains methods and notifications useful for implementing asynchronous background socket communication.

image with no caption

@interface NSFileHandle : NSObject
                                  // Initializers
   - (id)initWithFileDescriptor:(int)fd;
   - (id)initWithFileDescriptor:(int)fd 
                                 closeOnDealloc:(BOOL)closeopt;
   - (id)initWithNativeHandle:(void *)nativeHandle;
   - (id)initWithNativeHandle:(void *)nativeHandle 
                                 closeOnDealloc:(BOOL)closeopt;
                                  // Class Methods
   + (id)fileHandleForReadingAtPath:(NSString *)path;
   + (id)fileHandleForUpdatingAtPath:(NSString *)path;
   + (id)fileHandleForWritingAtPath:(NSString *)path;
   + (id)fileHandleWithNullDevice;
   + (id)fileHandleWithStandardError;
   + (id)fileHandleWithStandardInput;
   + (id)fileHandleWithStandardOutput;
                                  // Instance Methods
   - (void)acceptConnectionInBackgroundAndNotify;
   - (void)acceptConnectionInBackgroundAndNotifyForModes:(NSArray *)modes;
   - (NSData *)availableData;
   - (void)closeFile;
   - (int)fileDescriptor;
   - (void *)nativeHandle;
   - (unsigned long long)offsetInFile;
   - (NSData *)readDataOfLength:(unsigned int)length;
   - (NSData *)readDataToEndOfFile;
   - (void)readInBackgroundAndNotify;
   - (void)readInBackgroundAndNotifyForModes ...

Get Cocoa in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.