How Do I Select or Deselect an Annotation Programmatically?

You can select an annotation on the PSPDFPageView either by using selectAnnotation to select a specific annotation, or by using selectedAnnotations, which can be set to an array of annotations that lets you select multiple annotations at once:

// Get the current page view. It's usually the first in the array.
let pageView = pdfController.visiblePageViews[0]
// Select an annotation.
pageView.select(inkAnnotation, animated: false)
// Select multiple annotations.
pageView.selectedAnnotations = [firstAnnotation, secondAnnotation];

To deselect all currently selected annotations, set selectedAnnotations to an empty array, like this:

pageView.selectedAnnotations = []