Class: NSOutputStream

Inherits:
NSStream show all

Overview

The NSOutputStream class is a subclass of NSStream that provides write-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) outputStreamToBuffer(buffer, capacity:capacity)

Creates and returns an initialized output stream that can write to a provided buffer. The stream must be opened before it can be used.When the number of bytes written to buffer has reached capacity, the stream’s streamStatus will return NSStreamStatusAtEnd.

Parameters:

  • buffer (Integer)

    The buffer the output stream will write to.

  • capacity (Integer)

    The size of the buffer in bytes.

Returns:

  • (Object)

    An initialized output stream that can write to buffer.

+ (Object) outputStreamToFileAtPath(path, append:shouldAppend)

Creates and returns an initialized output stream for writing to a specified file. The stream must be opened before it can be used.

Parameters:

  • path (String)

    The path to the file the output stream will write to.

  • shouldAppend (Boolean)

    YES if newly written data should be appended to any existing file contents, NO otherwise.

Returns:

  • (Object)

    An initialized output stream that can write to path.

+ (Object) outputStreamToMemory

Creates and returns an initialized output stream that will write stream data to memory. The stream must be opened before it can be used.You retrieve the contents of the memory stream by sending the message propertyForKey: to the receiver with an argument of NSStreamDataWrittenToMemoryStreamKey.

Returns:

  • (Object)

    An initialized output stream that will write stream data to memory.

+ (Object) outputStreamWithURL(url, append:shouldAppend)

Creates and returns an initialized output stream for writing to a specified URL. The stream must be opened before it can be used.

Parameters:

  • url (NSURL)

    The URL to the file the output stream will write to.

  • shouldAppend (Boolean)

    YES if newly written data should be appended to any existing file contents, NO otherwise.

Returns:

  • (Object)

    An initialized output stream that can write to url.

Instance Method Details

- (Boolean) hasSpaceAvailable

Returns whether the receiver can be written to.

Returns:

  • (Boolean)

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

- (Object) initToBuffer(buffer, capacity:capacity)

Returns an initialized output stream that can write to a provided buffer. The stream must be opened before it can be used.When the number of bytes written to buffer has reached capacity, the stream’s streamStatus will return NSStreamStatusAtEnd.

Parameters:

  • buffer (Integer)

    The buffer the output stream will write to.

  • capacity (Integer)

    The size of the buffer in bytes.

Returns:

  • (Object)

    An initialized output stream that can write to buffer.

- (Object) initToFileAtPath(path, append:shouldAppend)

Returns an initialized output stream for writing to a specified file. The stream must be opened before it can be used.

Parameters:

  • path (String)

    The path to the file the output stream will write to.

  • shouldAppend (Boolean)

    YES if newly written data should be appended to any existing file contents, NO otherwise.

Returns:

  • (Object)

    An initialized output stream that can write to path.

- (Object) initToMemory

Returns an initialized output stream that will write to memory. The stream must be opened before it can be used.The contents of the memory stream are retrieved by passing the constant NSStreamDataWrittenToMemoryStreamKey to propertyForKey:.

Returns:

  • (Object)

    An initialized output stream that will write stream data to memory.

- (Object) initWithURL(url, append:shouldAppend)

Returns an initialized output stream for writing to a specified URL. The stream must be opened before it can be used.

Parameters:

  • url (NSURL)

    The URL to the file the output stream will write to.

  • shouldAppend (Boolean)

    YES if newly written data should be appended to any existing file contents, NO otherwise.

Returns:

  • (Object)

    An initialized output stream that can write to url.

- (Integer) write(buffer, maxLength:length)

Writes the contents of a provided data buffer to the receiver.

Parameters:

  • buffer (Integer)

    The data to write.

  • length (Integer)

    The length of the data buffer, in bytes.

Returns:

  • (Integer)

    The number of bytes actually written, or -1 if an error occurs. More information about the error can be obtained with streamError. If the receiver is a fixed-length stream and has reached its capacity, 0 is returned.