Mac Guides | Samples

MonoMac.Foundation.NSInputStream Class

A read-only input NSStream.

See Also: NSInputStream

Syntax

[MonoMac.Foundation.Register("NSInputStream", true)]
public class NSInputStream : NSStream

Remarks

Subclassing NSInputStream.

NSInputStream is a concrete subclass of NSStream you can use to give read-only access to stream data. For most cases this is sufficient, however if you want more control over the data, you can subclass NSInputStream. If you subclass NSInputStream you must provide an implementation of the following methods:

Providing a toll-free bridged NSInputStream subclass.

The methods required to provide a toll-free bridged NSInputStream subclass are considered private API, and may cause Apple to reject your app from the App Store.

An simple NSInputStream subclass will not work for all API that takes an NSInputStream. This is the case with NSMutableUrlRequest for instance, which actually expects an instance of a CFReadStream object. For this to work our NSInputStream subclass needs to be toll-free bridged to CFReadStream. This is done by overriding the following methods:

You must call also NSInputStream.Notify((valuetype MonoMac.CoreFoundation.CFStreamEventType) to inform the client when you have data available (or when you have any other relevant event), otherwise your input stream won't be read from.

Requirements

Namespace: MonoMac.Foundation
Assembly: XamMac (in XamMac.dll)
Assembly Versions: 0.0.0.0

The members of MonoMac.Foundation.NSInputStream are listed below.

See Also: NSStream

Public Constructors

Default constructor that initializes a new instance of this class with no parameters.
A constructor that initializes the object from the data stored in the unarchiver object.
Constructor to call on derived classes when the derived class has an [Export] constructor.
A constructor used when creating managed representations of unmanaged objects; Called by the runtime.

Public Properties

[read-only]
override
ClassHandleIntPtr. The handle for this class.

Public Methods

static
FromData(NSData) : NSInputStream
static
FromFile(String) : NSInputStream
static
FromUrl(NSUrl) : NSInputStream
HasBytesAvailable() : Boolean
Returna a boolean value indicating whether the stream has bytes available to be read.
Notify(CFStreamEventType)
Notifies consumers of events in the stream.
Read(Byte[], UInt32) : Int32
Reads data from the stream into the provided buffer.
Read(IntPtr, UInt32) : Int32
Reads data from the stream into the provided buffer. You should not call this method directly, you should call NSInputStream.Read(byte[],uint) instead. This method is for NSInputStream subclasses to implement.
ScheduleInCFRunLoop(CFRunLoop, NSString)
Schedules the stream in a RunLoop.
UnscheduleInCFRunLoop(CFRunLoop, NSString)
Unschedules the stream from a RunLoop.

Protected Methods

override
Dispose(Boolean)
Releases the resourced used by the NSInputStream object.
GetBuffer(out IntPtr, out UInt32) : Boolean
This method can return a pointer to a buffer the caller can read data from.
SetCFClientFlags(CFStreamEventType, IntPtr, IntPtr) : Boolean
Adds a client for the stream. This method is not supposed to be called by managed code, it will be called by consumers of the straem. When overriding it make sure to call the base implementation.