PSPDFUsernameHelper


@interface PSPDFUsernameHelper : NSObject

A helper that can be used to present a dialog, allowing the user to specify the annotation author name.

  • Access or set the default annotation username.

    This property uses NSUserDefaults for storage (the PSPDFDocumentDefaultAnnotationUsernameKey key).

    The default will be inferred based on the device name and some internal logic. This is also the value that will be used if the property is reset by setting nil.

    Note

    The username set here will be used as the default value of PSPDFDocument.defaultAnnotationUsername for newly created documents. Updating this value will not update the value on existing documents.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic, null_resettable, class)
        NSString *defaultAnnotationUsername;

    Swift

    class var defaultAnnotationUsername: String! { get set }
  • Declaration

    Objective-C

    @property (readonly, nonatomic, class) BOOL isDefaultAnnotationUserNameSet;

    Swift

    class var isDefaultAnnotationUserNameSet: Bool { get }
  • Asks for the default new annotation username.

    This will only display UI if enabled in the controller configuration and if the username is not already set.

    Use this call if you’re presenting a custom annotation creation UI (e.g., a custom toolbar). Present your UI / toolbar inside the completion block. The behavior above ensures that the UI action is not performed if the dialog is canceled.

    Declaration

    Objective-C

    + (void)askForDefaultAnnotationUsernameIfNeeded:
                (nonnull PSPDFViewController *)pdfViewController
                                    completionBlock:
                                        (nonnull void (^)(NSString *_Nonnull))
                                            completionBlock;

    Swift

    class func ask(forDefaultAnnotationUsernameIfNeeded pdfViewController: PSPDFViewController, completionBlock: @escaping (String) -> Void)

    Parameters

    pdfViewController

    The view controller to use as the presenting view controller.

    completionBlock

    Called when the UI is dismissed, unless the displayed dialog is canceled.

  • Asks for a new default username on the provided view controller.

    See

    askForDefaultAnnotationUsernameIfNeeded:completionBlock:

    Declaration

    Objective-C

    - (void)
        askForDefaultAnnotationUsername:(nonnull UIViewController *)viewController
                          suggestedName:(nullable NSString *)suggestedName
                        completionBlock:
                            (nonnull void (^)(NSString *_Nonnull))completionBlock;

    Swift

    func ask(forDefaultAnnotationUsername viewController: UIViewController, suggestedName: String?, completionBlock: @escaping (String) -> Void)

    Parameters

    viewController

    The view controller to use as the presenting view controller.

    suggestedName

    A username to be pre-filled in the dialog. If nil we’ll try to guess the username.

    completionBlock

    Called when the UI is dismissed, unless the displayed dialog is canceled.