PSPDFDataSink

Objective-C

@protocol PSPDFDataSink <NSObject>

Swift

protocol DataSink : NSObjectProtocol

This protocol allows an implementation of DataProviding to return an object that can be used to re-write/append to a data source.

  • isFinished should return true if finish has been called. This is used for consistency checks to make sure writing has actually finished.

    Declaration

    Objective-C

    @property (nonatomic, readonly) BOOL isFinished;

    Swift

    var isFinished: Bool { get }
  • The options the receiver was initialized with, describing its behavior for writing.

    Declaration

    Objective-C

    @property (nonatomic, readonly) PSPDFDataSinkOptions options;

    Swift

    var options: DataSinkOptions { get }
  • This method should append the given data to your data source. If your data source is full or encounters a error, return false and the write operation will be marked as a failure.

    Declaration

    Objective-C

    - (BOOL)writeData:(nonnull NSData *)data;

    Swift

    func write(_ data: Data) -> Bool
  • This is called at the end of all the write operations. This gives you the opportunity to finish up any compression or encryption operation. After this, writeData: will no longer be called and the PSPDFDataSink is finished. If any error occurs, return false and the write operation will be marked as a failure.

    Declaration

    Objective-C

    - (BOOL)finish;

    Swift

    func finish() -> Bool