See Also: NSInputStream
public class NSInputStream : NSStream
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:
- NSInputStream.Read(IntPtr,uint): In this method you must write bytes to the provided buffer. You can use Marshal.Copy(byte,int,IntPtr,int) to write from a byte array to the provided buffer. Return the number of bytes actually written.
- NSInputStream.GetBuffer(byte,uint): Return a pointer to a buffer where bytes can be read. You can return false from this method and just implement NSInputStream.Read(IntPtr,uint).
- NSInputStream.HasBytesAvailable: Use this method to indicate when your stream has data to be read.
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:
- NSInputStream.SetCFClientFlags(CFStreamEventType,IntPtr,IntPtr): This method is called to register a client to notify of events in your stream. You must call the base implementation, with the exact arguments passed in.
- NSInputStream.ScheduleInCFRunLoop(IntPtr,string): Depending on what you're doing to provide the data, you will need to schedule in a run loop when this method is called. You should not call the base implementation for this method.
- NSInputStream.UnscheduleInCFRunLoop(IntPtr,string): This is called when you need to unschedule from a run loop. You should not call the base implementation for this method.
Assembly: XamMac (in XamMac.dll)
Assembly Versions: 0.0.0.0
The members of MonoMac.Foundation.NSInputStream are listed below.
See Also: NSStream
|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.|
Returna a boolean value indicating whether the stream has bytes available to be read.
Notifies consumers of events in the stream.
Reads data from the stream into the provided buffer.
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.
Schedules the stream in a RunLoop.
Unschedules the stream from a RunLoop.
Releases the resourced used by the NSInputStream object.
|GetBuffer(out IntPtr, out UInt32)|
This method can return a pointer to a buffer the caller can read data from.
|SetCFClientFlags(CFStreamEventType, IntPtr, IntPtr)|
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.