Class: NSInputStream

Inherits:
NSStream show all

Overview

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

Class Method Summary (collapse)

Instance Method Summary (collapse)

Methods inherited from NSStream

#close, #delegate, #open, #propertyForKey:, #removeFromRunLoop:forMode:, #scheduleInRunLoop:forMode:, #setDelegate:, #setProperty:forKey:, #streamError, #streamStatus

Methods inherited from NSObject

#!, #!=, #!~, #, #==, #===, #=~, #Rational, #__callee__, #__method__, #__send__, #__type__, `, alloc, allocWithZone:, #autoContentAccessingProxy, autoload, autoload?, autorelease_pool, #awakeAfterUsingCoder:, binding, block_given?, caller, cancelPreviousPerformRequestsWithTarget:, cancelPreviousPerformRequestsWithTarget:selector:object:, catch, class, classFallbacksForKeyedArchiver, #classForCoder, #classForKeyedArchiver, classForKeyedUnarchiver, #clone, conformsToProtocol:, #copy, copyWithZone:, #dealloc, #define_singleton_method, description, display, #doesNotRecognizeSelector:, #dup, #enum_for, #eql?, #equal?, #extend, fail, #finalize, format, #forwardInvocation:, #forwardingTargetForSelector:, framework, #freeze, #frozen?, getpass, gets, global_variables, #init, initialize, #initialize_clone, #initialize_copy, #initialize_dup, #inspect, instanceMethodForSelector:, instanceMethodSignatureForSelector:, #instance_eval, #instance_exec, #instance_of?, #instance_variable_defined?, #instance_variable_get, #instance_variable_set, #instance_variables, instancesRespondToSelector:, isSubclassOfClass:, #is_a?, iterator?, #kind_of?, lambda, load, load_bridge_support_file, load_plist, local_variables, loop, #method, #methodForSelector:, #methodSignatureForSelector:, #methods, #mutableCopy, mutableCopyWithZone:, new, #nil?, open, p, #performSelector:onThread:withObject:waitUntilDone:, #performSelector:onThread:withObject:waitUntilDone:modes:, #performSelector:withObject:afterDelay:, #performSelector:withObject:afterDelay:inModes:, #performSelectorInBackground:withObject:, #performSelectorOnMainThread:withObject:waitUntilDone:, #performSelectorOnMainThread:withObject:waitUntilDone:modes:, print, printf, #private_methods, proc, #protected_methods, #public_method, #public_methods, #public_send, putc, puts, raise, rand, readline, readlines, #replacementObjectForCoder:, #replacementObjectForKeyedArchiver:, require, resolveClassMethod:, resolveInstanceMethod:, #respond_to?, #respond_to_missing?, select, #send, setVersion:, #singleton_methods, sprintf, srand, superclass, #taint, #tainted?, #tap, test, throw, #to_plist, #to_s, trace_var, trap, #trust, #untaint, untrace_var, #untrust, #untrusted?, version

Constructor Details

This class inherits a constructor from NSObject

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class NSObject

Class Method Details

+ (Object) inputStreamWithData(data)

Creates and returns an initialized NSInputStream object for reading from a given NSData object.

Parameters:

  • data (NSData)

    The data object from which to read. The contents of data are copied.

Returns:

  • (Object)

    An initialized NSInputStream object for reading from data. If data is not an NSData object, this method returns nil.

+ (Object) inputStreamWithFileAtPath(path)

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

Parameters:

  • path (String)

    The path to the file.

Returns:

  • (Object)

    An initialized NSInputStream object that reads data from the file at path. If the file specified by path doesn’t exist or is unreadable, returns nil.

+ (Object) inputStreamWithURL(url)

Creates and returns an initialized NSInputStream object that reads data from the file at a given URL.

Parameters:

  • url (NSURL)

    The URL to the file.

Returns:

  • (Object)

    An initialized NSInputStream object that reads data from the URL at url. If the file specified by url doesn’t exist or is unreadable, returns nil.

Instance Method Details

- (Boolean) getBuffer(buffer, length:len)

Returns by reference a pointer to a read buffer and, by reference, the number of bytes available, and returns a Boolean value that indicates whether the buffer is available.

Parameters:

  • buffer (Pointer)

    Upon return, contains a pointer to a read buffer. The buffer is only valid until the next stream operation is performed.

  • len (Integer)

    Upon return, contains the number of bytes available.

Returns:

  • (Boolean)

    YES if the buffer is available, otherwise NO.Subclasses of NSInputStream may return NO if this operation is not appropriate for the stream type.

- (Boolean) hasBytesAvailable

Returns a Boolean value that indicates whether the receiver has bytes available to read.

Returns:

  • (Boolean)

    YES if the receiver has bytes available to read, otherwise NO. May also return YES if a read must be attempted in order to determine the availability of bytes.

- (Object) initWithData(data)

Initializes and returns an NSInputStream object for reading from a given NSData object.

Parameters:

  • data (NSData)

    The data object from which to read. The contents of data are copied.

Returns:

- (Object) initWithFileAtPath(path)

Initializes and returns an NSInputStream object that reads data from the file at a given path.

Parameters:

  • path (String)

    The path to the file.

Returns:

  • (Object)

    An initialized NSInputStream object that reads data from the file at path. If the file specified by path doesn’t exist or is unreadable, returns nil.

- (Object) initWithURL(url)

Initializes and returns an NSInputStream object that reads data from the file at a given URL.

Parameters:

  • url (NSURL)

    The URL to the file.

Returns:

  • (Object)

    An initialized NSInputStream object that reads data from the file at url. If the file specified by url doesn’t exist or is unreadable, returns nil.

- (Integer) read(buffer, maxLength:len)

Reads up to a given number of bytes into a given buffer.

Parameters:

  • buffer (Integer)

    A data buffer. The buffer must be large enough to contain the number of bytes specified by len.

  • len (Integer)

    The maximum number of bytes to read.

Returns:

  • (Integer)

    A number indicating the outcome of the operation: