ZDCInputStream

@interface ZDCInputStream : NSInputStream <NSStreamDelegate> {
  NSInputStream *inputStream;
  NSStreamStatus streamStatus;
  NSError *streamError;
  id<NSStreamDelegate> delegate;
  NSNumber *fileMinOffset;
  NSNumber *fileMaxOffset;
  NSNumber *returnEOFOnWouldBlock;
}

ZDCInputStream is an abstract NSInputStream that’s designed to be subclassed.

Its benefit is that it automatically handles the NSRunLoop/CFRunLoop stuff. That is, it makes it easier to plug a custom NSInputStream into an NSRunLoop or NSURLSessionTask.

  • The underlying stream. Exposed to outside world via underlyingInputStream (readonly) property.

    Declaration

    Objective-C

    NSInputStream *inputStream
  • Set this when streamStatus changes. Then use sendEvent: if needed.

    Declaration

    Objective-C

    NSStreamStatus streamStatus
  • Set this when an error occurs. Then use sendEvent: if needed.

    Declaration

    Objective-C

    NSError *streamError
  • Unavailable

    Every stream has a delegate

    Declaration

    Objective-C

    id<NSStreamDelegate> delegate
  • Direct access to configured value.

    See

    ZDCStreamFileMinOffset

    See

    supportsFileMinMaxOffset

    Declaration

    Objective-C

    NSNumber *fileMinOffset
  • Direct access to configured value.

    See

    ZDCStreamFileMaxOffset

    See

    supportsFileMinMaxOffset

    Declaration

    Objective-C

    NSNumber *fileMaxOffset
  • Direct access to configured value.

    See

    ZDCStreamReturnEOFOnWouldBlock

    See

    supportsEOFOnWouldBlock

    Declaration

    Objective-C

    NSNumber *returnEOFOnWouldBlock
  • The underlying stream that’s powering this stream.

    ZDCInputStream’s may have multiple layers of stream / conversions. You can use this property to peel back the layers.

    Declaration

    Objective-C

    @property (readonly, nonatomic) NSInputStream *underlyingInputStream;

    Swift

    var underlyingInputStream: InputStream! { get }
  • The retainToken from CacheManager. Set this property to prevent the CacheManager from deleting the file before we can open it.

    Declaration

    Objective-C

    @property (readwrite, strong, nonatomic) id retainToken;

    Swift

    var retainToken: Any! { get set }
  • Subclasses should return YES if the ZDCStreamFileMinOffset & ZDCStreamFileMaxOffset properties are supported. Otherwise ZDCInputStream will refuse to set them, and return NO in setProperty:forKey:.

    Declaration

    Objective-C

    - (BOOL)supportsFileMinMaxOffset;

    Swift

    func supportsFileMinMaxOffset() -> Bool
  • Subclasses should return YES if the ZDCStreamReturnEOFOnWouldBlock property is supported. Otherwise ZDCInputStream will refuse to set it, and will return NO in setProperty:forKey:.

    Declaration

    Objective-C

    - (BOOL)supportsEOFOnWouldBlock;

    Swift

    func supportsEOFOnWouldBlock() -> Bool