How Do I Programmatically Add Annotations to the Saved Annotations List?

To programmatically add annotations to the saved annotation list, you need to create a new AnnotationSet and append it to the annotation sets stored in SavedAnnotationsViewController.sharedAnnotationStore, like so:

// New annotations to save.
let annotations = /* ... */

// Get the default annotation set store.
let store = SavedAnnotationsViewController.sharedAnnotationStore

// Modify the stored annotation sets.
try store.modifyAnnotationSets { annotationSets in
    annotationSets.append(AnnotationSet(annotations: annotations, copyAnnotations: true))
// New annotations to save.
NSArray<PSPDFAnnotation *> *annotations = /* ... */;

// Get the default annotation set store.
id<PSPDFAnnotationSetStore> store = PSPDFSavedAnnotationsViewController.sharedAnnotationStore;

// Get the currently stored annotation sets.
NSMutableArray<PSPDFAnnotationSet *> *annotationSets = [store fetchAnnotationSetsWithError:&error].mutableCopy;

// Append the new annotations.
[annotationSets addObject:[[PSPDFAnnotationSet alloc] initWithAnnotations:annotations copyAnnotations:YES]];

// Modify the stored annotation sets.
[store setAnnotationSets:annotationSets.copy error:&error];