O'Reilly logo

Cocoa in a Nutshell by James Duncan Davidson, Michael Beam

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required