Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我似乎无法在任何地方找到答案,但是read:maxLength:在NSInputStream数据可用或出现错误之前一直阻塞,或者我是否需要hasBytesAvailable在尝试阅读之前进行轮询?
read:maxLength:
NSInputStream
hasBytesAvailable
是的,read:maxLength:阻塞直到至少有一个字节可用,或者发生错误或流到达 EOS。它也会阻塞,直到流打开之后。
是否要进行轮询,或者是否对阻塞感到满意,或者是否要实现流委托取决于您。建议使用流代理。