Up

NSStream documentation

Authors

Derek Zhou (derekzhou@gmail.com)

Copyright: (C) 2006 Free Software Foundation, Inc.


Contents -

  1. Software documentation for the NSInputStream class
  2. Software documentation for the NSOutputStream class
  3. Software documentation for the NSStream class
  4. Software documentation for the NSObject(NSStreamDelegate) informal protocol
  5. Software documentation for the NSStreamDelegate protocol

Software documentation for the NSInputStream class

NSInputStream : NSStream

Declared in:
Foundation/NSStream.h
Availability: MacOS-X 10.4.0, Base 1.2.0

NSInputStream is a subclass of NSStream that provides read-only stream functionality.
Method summary

inputStreamWithData: 

+ (id) inputStreamWithData: (NSData*)data;
Availability: MacOS-X 10.4.0, Base 1.2.0

Creates and returns an initialized NSInputStream object for reading from data.

inputStreamWithFileAtPath: 

+ (id) inputStreamWithFileAtPath: (NSString*)path;
Availability: MacOS-X 10.4.0, Base 1.2.0

Creates and returns an initialized NSInputStream object that reads data from the file at the specified path.

getBuffer: length: 

- (BOOL) getBuffer: (uint8_t**)buffer length: (NSUInteger*)len;
Availability: MacOS-X 10.4.0, Base 1.2.0

Returns a pointer to the read buffer in buffer and, by reference, the number of bytes available in len.

hasBytesAvailable 

- (BOOL) hasBytesAvailable;
Availability: MacOS-X 10.4.0, Base 1.2.0

Returns YES if the receiver has bytes available to read. The receiver may also return YES if a read must be attempted in order to determine the availability of bytes.

initWithData: 

- (id) initWithData: (NSData*)data;
Availability: MacOS-X 10.4.0, Base 1.2.0

Returns an initialized NSInputStream object for reading from data.

initWithFileAtPath: 

- (id) initWithFileAtPath: (NSString*)path;
Availability: MacOS-X 10.4.0, Base 1.2.0

Returns an initialized NSInputStream object for reading from the file at the specified path.

read: maxLength: 

- (NSInteger) read: (uint8_t*)buffer maxLength: (NSUInteger)len;
Availability: MacOS-X 10.4.0, Base 1.2.0

Reads up to len bytes into buffer, returning the actual number of bytes read.

Software documentation for the NSOutputStream class

NSOutputStream : NSStream

Declared in:
Foundation/NSStream.h
Availability: MacOS-X 10.4.0, Base 1.2.0

NSOutputStream is a subclass of NSStream that provides write-only stream functionality.
Method summary

outputStreamToBuffer: capacity: 

+ (id) outputStreamToBuffer: (uint8_t*)buffer capacity: (NSUInteger)capacity;
Availability: MacOS-X 10.4.0, Base 1.2.0

Creates and returns an initialized NSOutputStream object that can write to buffer, up to a maximum of capacity bytes.

outputStreamToFileAtPath: append: 

+ (id) outputStreamToFileAtPath: (NSString*)path append: (BOOL)shouldAppend;
Availability: MacOS-X 10.4.0, Base 1.2.0

Creates and returns an initialized NSOutputStream object for writing to the file specified by path.

outputStreamToMemory 

+ (id) outputStreamToMemory;
Availability: MacOS-X 10.4.0, Base 1.2.0

Creates and returns an initialized NSOutputStream object that will write stream data to memory.

hasSpaceAvailable 

- (BOOL) hasSpaceAvailable;
Availability: MacOS-X 10.4.0, Base 1.2.0

Returns YES if the receiver can be written to, or if a write must be attempted in order to determine if space is available.

initToBuffer: capacity: 

- (id) initToBuffer: (uint8_t*)buffer capacity: (NSUInteger)capacity;
Availability: MacOS-X 10.4.0, Base 1.2.0

Returns an initialized NSOutputStream object that can write to buffer, up to a maximum of capacity bytes.

initToFileAtPath: append: 

- (id) initToFileAtPath: (NSString*)path append: (BOOL)shouldAppend;
Availability: MacOS-X 10.4.0, Base 1.2.0

Returns an initialized NSOutputStream object for writing to the file specified by path.
If shouldAppend is YES, newly written data will be appended to any existing file contents.

initToMemory 

- (id) initToMemory;
Availability: MacOS-X 10.4.0, Base 1.2.0

Returns an initialized NSOutputStream object that will write to memory.

write: maxLength: 

- (NSInteger) write: (const uint8_t*)buffer maxLength: (NSUInteger)len;
Availability: MacOS-X 10.4.0, Base 1.2.0

Writes the contents of buffer, up to a maximum of len bytes, to the receiver.

Software documentation for the NSStream class

NSStream : NSObject

Declared in:
Foundation/NSStream.h
Availability: MacOS-X 10.4.0, Base 1.2.0

NSStream is an abstract class for objects representing streams.
Method summary

getStreamsToHost: port: inputStream: outputStream: 

+ (void) getStreamsToHost: (NSHost*)host port: (NSInteger)port inputStream: (NSInputStream**)inputStream outputStream: (NSOutputStream**)outputStream;
Availability: MacOS-X 10.4.0, Base 1.2.0

Creates and returns by reference an NSInputStream object and NSOutputStream object for a socket connection with the specified port on host.

close 

- (void) close;
Availability: MacOS-X 10.4.0, Base 1.2.0

Closes the receiver.
Repeated calls to this method on the same stream are quietly ignored.

delegate 

- (id) delegate;
Availability: MacOS-X 10.4.0, Base 1.2.0

Returns the receiver's delegate.

open 

- (void) open;
Availability: MacOS-X 10.4.0, Base 1.2.0

Opens the receiving stream.
Upon completion of the open operation, an NSStreamEventOpenCompleted event is sent to the recevier's delegate.
Repeated calls to this method on the same stream are quietly ignored.

propertyForKey: 

- (id) propertyForKey: (NSString*)key;
Availability: MacOS-X 10.4.0, Base 1.2.0

Returns the receiver's property for the specified key.

removeFromRunLoop: forMode: 

- (void) removeFromRunLoop: (NSRunLoop*)aRunLoop forMode: (NSString*)mode;
Availability: MacOS-X 10.4.0, Base 1.2.0

Removes the receiver from the NSRunLoop specified by aRunLoop running in the mode.
Attempts to remove the receiver from a run loop or a mode in which it has not been scheduled are quietly ignored.

scheduleInRunLoop: forMode: 

- (void) scheduleInRunLoop: (NSRunLoop*)aRunLoop forMode: (NSString*)mode;
Availability: MacOS-X 10.4.0, Base 1.2.0

Schedules the receiver on aRunLoop using the specified mode.
You must not attempt to add a stream to more than one run loop, but you may call this method multiple times to add the receiver in different modes for the same run loop.

setDelegate: 

- (void) setDelegate: (id)delegate;
Availability: MacOS-X 10.4.0, Base 1.2.0

Sets the receiver's delegate.

setProperty: forKey: 

- (BOOL) setProperty: (id)property forKey: (NSString*)key;
Availability: MacOS-X 10.4.0, Base 1.2.0

Sets the value of the property specified by key to property, returns YES if the key-value pair are accepted by the receiver.

streamError 

- (NSError*) streamError;
Availability: MacOS-X 10.4.0, Base 1.2.0

Returns an NSError object representing the stream error, or nil if no error has been encountered.

streamStatus 

- (NSStreamStatus) streamStatus;
Availability: MacOS-X 10.4.0, Base 1.2.0

Returns the receiver's status.

Software documentation for the NSObject(NSStreamDelegate) informal protocol

NSObject(NSStreamDelegate)

Declared in:
Foundation/NSStream.h
Availability: MacOS-X 10.4.0, Base 1.2.0

Informal protocol for delegates of instance of the NSStream class.
Method summary

stream: handleEvent: 

- (void) stream: (NSStream*)sStream handleEvent: (NSStreamEvent)anEvent;
Availability: MacOS-X 10.4.0, Base 1.2.0

Description forthcoming.

Software documentation for the NSStreamDelegate protocol

NSStreamDelegate

Declared in:
Foundation/NSStream.h
Conforms to:
NSObject
Availability: MacOS-X 10.7.0, Base 1.2.0

Description forthcoming.
Method summary

stream: handleEvent: 

- (void) stream: (NSStream*)sStream handleEvent: (NSStreamEvent)anEvent;
Availability: MacOS-X 10.7.0, Base 1.2.0

Description forthcoming.


Up