Stream

Stream是单向的,

Reading From Input Streams:

1.Create and initilize an instance of NSInputStream from s source of data;

2.Sechedule the stream object on a run loop and open the stream;

3.Handle the events that the stream object reports to its delegate;

4.When there is no data to read,dispose the stream object.

Writing To Output Streams:

1.Create and initialize an instance of NSOutputStream with a repository for the written data.Also set a delegate.

2.Sechedule the stream object on a run loop and open the stream;

3.Handle the events that the stream object reports to its delegate.

4.If the stream object has written data to memory, obtain the data by requesting the NSStreamDataWrittenToMemoryStreamKey property.

5.When there is no more data to write, dispose of the stream object.

原文地址:https://www.cnblogs.com/wustlj/p/2354001.html