What’s New in iOS 13 QuickLook?

Besides the addition of QLPreviewItemEditingMode , the QLPreviewControllerDelegate protocol introduces three new optional delegate methods.

Handling editing mode capabilities

We can handle the editing mode by implementing the following method:

optional func previewController(_ controller: QLPreviewController, editingModeFor previewItem: QLPreviewItem) -> QLPreviewItemEditingMode

In the above method, we can set the return type as createCopy , default or updateContents to handle the editing results accordingly. updateContents overwrites the content of the QLPreviewItems in the FileManager . By default editing mode is off.

Saving the edited contents

Once the edit is done, we can save the modified contents using the below optional method:

func previewController(_ controller: QLPreviewController, didSaveEditedCopyOf previewItem: QLPreviewItem, at modifiedContentsURL: URL)

The above method gets triggered when the EditingMode is createsCopy . It returns the URL of the modified content(the content resides in a temp location). We can then choose to handle the URL and save it in FileManager .

Notifying about edited contents

We can choose to update the user interface after being notified of the successful update of the QLPreviewItem. This gets triggered when the Editing Mode is updatesContent :

func previewController(_ controller: QLPreviewController, didUpdateContentsOf previewItem: QLPreviewItem)