PSPDFLibraryDataSource

@protocol PSPDFLibraryDataSource <NSObject>

The PSPDFLibraryDataSource protocol is adopted by an object that provides the documents to be indexed by a PSPDFLibrary. These methods will not be called on the main queue, and can take long to execute. If you are implementing this protocol yourself and not using PSPDFLibraryFileSystemDataSource, please read the documentation carefully.

  • Notifies the data source that the library is about to begin the indexing process. Perform any required setup here.

    Declaration

    Objective-C

    - (void)libraryWillBeginIndexing:(nonnull PSPDFLibrary *)library;

    Swift

    optional func libraryWillBeginIndexing(_ library: PSPDFLibrary)

    Parameters

    library

    The library that is about to begin indexing.

  • Asks the data source for the UIDs of the documents to be indexed by the library. This method should not return any uids that are already indexed, or they will be reindexed. This is useful in cases when the document was modified, and its contents changed and therefore need the index to be updated as well.

    Declaration

    Objective-C

    - (nonnull NSArray<NSString *> *)uidsOfDocumentsToBeIndexedByLibrary:
        (nonnull PSPDFLibrary *)library;

    Swift

    func uidsOfDocumentsToBeIndexed(by library: PSPDFLibrary) -> [String]

    Parameters

    library

    The library object requesting this information.

    Return Value

    An array of NSStrings each corresponding to the a PSPDFDocument UID.

  • Asks the data source for the UIDs for documents to be removed. This method will be called by the library at the start of its indexing process to allow for removal of any non-existing documents. This is especially necessary when the indexToSpotlight property is set to YES, as having deleted documents show up in indexed spotlight search is not good.

    Declaration

    Objective-C

    - (nonnull NSArray<NSString *> *)uidsOfDocumentsToBeRemovedFromLibrary:
        (nonnull PSPDFLibrary *)library;

    Swift

    func uidsOfDocumentsToBeRemoved(from library: PSPDFLibrary) -> [String]

    Parameters

    library

    The library object requesting this information

    Return Value

    An array of NSStrings each corresponding to a previously indexed PSPDFDocument UID.

  • Asks the data source for a document with the specified UID

    Warning

    This method may be called even without libraryWillBeginIndexing: being called first, if a document is required for Spotlight.

    Declaration

    Objective-C

    - (nullable PSPDFDocument *)library:(nonnull PSPDFLibrary *)library
                        documentWithUID:(nonnull NSString *)UID;

    Swift

    func library(_ library: PSPDFLibrary, documentWithUID UID: String) -> PSPDFDocument?

    Parameters

    library

    The library that requires the document.

    UID

    The UID of the requested document.

    Return Value

    A document with a matching UID, or nil if no such document exists.