PSPDFDataSink

@protocol PSPDFDataSink <NSObject>

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

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

    Declaration

    Objective-C

    @property (readonly, nonatomic) BOOL isFinished;

    Swift

    var isFinished: Bool { get }
  • This method should append the given data to your data source. If your data source is full or encounters a error, return NO 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 NO and the write operation will be marked as a failure.

    Declaration

    Objective-C

    - (BOOL)finish;

    Swift

    func finish() -> Bool