PTDocumentControllerDelegate

@protocol PTDocumentControllerDelegate <NSObject>

The methods declared by the PTDocumentControllerDelegate protocol allow the adopting delegate to respond to messages from the PTDocumentController class.

  • The document controller no longer has a valid document, and needs to be closed.

    Declaration

    Objective-C

    - (void)documentControllerDidBecomeInvalid:
        (nonnull PTDocumentController *)documentController;

    Swift

    optional func documentControllerDidBecomeInvalid(_ documentController: PTDocumentController)
  • The document controller has opened a document.

    Declaration

    Objective-C

    - (void)documentControllerDidOpenDocument:
        (nonnull PTDocumentController *)documentController;

    Swift

    optional func documentControllerDidOpenDocument(_ documentController: PTDocumentController)
  • Called when an error occurs when opening a document.

    Declaration

    Objective-C

    - (void)documentController:(nonnull PTDocumentController *)documentController
        didFailToOpenDocumentWithError:(nonnull NSError *)error;

    Swift

    optional func documentController(_ documentController: PTDocumentController, didFailToOpenDocumentWithError error: Error)
  • This method allows the delegate to control whether a cached document should be exported to a different location and is called after a remote document has been fully downloaded or a non-PDF document has finished converting.

    If this method is not implemented, the cached document will be exported.

    Declaration

    Objective-C

    - (BOOL)documentController:(nonnull PTDocumentController *)documentController
        shouldExportCachedDocumentAtURL:(nonnull NSURL *)cachedDocumentUrl;

    Swift

    optional func documentController(_ documentController: PTDocumentController, shouldExportCachedDocumentAt cachedDocumentUrl: URL) -> Bool
  • Implement to override default save location when non-PDFs and remote documents are opened via openDocumentWithURL. If this method is not implemented or nil is returned, the document will be saved to the Documents directory with a unique name.

    Declaration

    Objective-C

    - (nullable NSURL *)documentController:
                            (nonnull PTDocumentController *)documentController
            destinationURLForDocumentAtURL:(nonnull NSURL *)sourceUrl;

    Swift

    optional func documentController(_ documentController: PTDocumentController, destinationURLForDocumentAt sourceUrl: URL) -> URL?
  • This method allows the delegate to control whether a cached document should be deleted after it has been exported to a different location.

    If this method is not implemented, the cached document will be deleted.

    Declaration

    Objective-C

    - (BOOL)documentController:(nonnull PTDocumentController *)documentController
        shouldDeleteCachedDocumentAtURL:(nonnull NSURL *)cachedDocumentUrl;

    Swift

    optional func documentController(_ documentController: PTDocumentController, shouldDeleteCachedDocumentAt cachedDocumentUrl: URL) -> Bool
  • This method allows the delegate to control whether the text search view controller should be dismissed when the document controller’s view disappears.

    If this method is not implemented, the text search view controller will be dismissed.

    Declaration

    Objective-C

    - (BOOL)documentControllerShouldAutomaticallyDismissSearchViewController:
        (nonnull PTDocumentController *)documentViewController;

    Swift

    optional func documentControllerShouldAutomaticallyDismissSearchViewController(_ documentViewController: PTDocumentController) -> Bool