---
title: "Using automatic saving safely"
canonical_url: "https://www.nutrient.io/guides/ios/best-practices/using-automatic-saving-safely/"
md_url: "https://www.nutrient.io/guides/ios/best-practices/using-automatic-saving-safely.md"
last_updated: "2026-05-23T00:08:18.103Z"
description: "Learn how to use automatic saving safely by choosing coordinated file access, understanding save behavior, and reusing one document instance per backing file."
---

[`Document`](https://www.nutrient.io/api/ios/documentation/pspdfkit/document) works with local files and custom data providers. The behavior around file observation, conflict resolution, and automatic saving depends on which path you choose.

## Recommended default

If you’re opening a file that already exists on disk, use [`Document(url:)`](https://www.nutrient.io/api/ios/documentation/pspdfkit/document/init(url:)) to create the document.

For local file URLs, [`Document(url:)`](https://www.nutrient.io/api/ios/documentation/pspdfkit/document/init(url:)) creates either a [`CoordinatedFileDataProvider`](https://www.nutrient.io/api/ios/documentation/pspdfkit/coordinatedfiledataprovider) or a [`FileDataProvider`](https://www.nutrient.io/api/ios/documentation/pspdfkit/filedataprovider), depending on [`SDK.Setting.fileCoordinationEnabled`](https://www.nutrient.io/api/ios/documentation/pspdfkit/sdk/setting/filecoordinationenabled). That setting is enabled by default, so the standard setup uses a [`CoordinatedFileDataProvider`](https://www.nutrient.io/api/ios/documentation/pspdfkit/coordinatedfiledataprovider).

With a coordinated file-backed document, Nutrient can:

- Observe changes to the underlying file.

- Participate in the built-in conflict resolution flow when conflict resolution is available.

When using [`PDFView`](https://www.nutrient.io/api/ios/documentation/pspdfkitui/pdfview) and [`PDFViewController`](https://www.nutrient.io/api/ios/documentation/pspdfkitui/pdfviewcontroller), file presenters are registered for you. If you present documents in custom view controllers, follow the [file coordination](https://www.nutrient.io/guides/ios/features/file-coordination.md) guide to register and unregister the document’s file presenters.

## Data provider choice

If you create a document with [`Document(dataProviders:)`](https://www.nutrient.io/api/ios/documentation/pspdfkit/document/init(dataproviders:)), the behavior depends on the provider you pass in:

- [`CoordinatedFileDataProvider`](https://www.nutrient.io/api/ios/documentation/pspdfkit/coordinatedfiledataprovider) keeps file coordination enabled.

- [`FileDataProvider`](https://www.nutrient.io/api/ios/documentation/pspdfkit/filedataprovider) is the non-coordinated file-backed option.

This matters because only coordinated providers expose file presenter callbacks and conflict resolution APIs. If you pass [`FileDataProvider`](https://www.nutrient.io/api/ios/documentation/pspdfkit/filedataprovider) yourself, Nutrient can still read and write the file, but it won’t observe external file changes through file presentation callbacks or offer coordinated conflict resolution for that provider.

## Choose a save setup

[`PDFView`](https://www.nutrient.io/api/ios/documentation/pspdfkitui/pdfview) and [`PDFViewController`](https://www.nutrient.io/api/ios/documentation/pspdfkitui/pdfviewcontroller) save automatically only when [`isAutosaveEnabled`](https://www.nutrient.io/api/ios/documentation/pspdfkitui/pdfconfiguration/isautosaveenabled) is `true`. If automatic saving is disabled, no automatic save runs, and your app is responsible for choosing when to save.

When automatic saving is enabled, [`allowBackgroundSaving`](https://www.nutrient.io/api/ios/documentation/pspdfkitui/pdfconfiguration/allowbackgroundsaving) controls whether Nutrient saves in the background or synchronously.

The default value follows [`SDK.Setting.fileCoordinationEnabled`](https://www.nutrient.io/api/ios/documentation/pspdfkit/sdk/setting/filecoordinationenabled). In the standard coordinated setup, that means [`allowBackgroundSaving`](https://www.nutrient.io/api/ios/documentation/pspdfkitui/pdfconfiguration/allowbackgroundsaving) defaults to `true`.

Asynchronous (background) saving is better for UI responsiveness because it doesn’t block the UI while the file is written. The tradeoff is that the save can still be in progress after your code continues. If your app closes a viewer, stops using its [`Document`](https://www.nutrient.io/api/ios/documentation/pspdfkit/document), and creates another [`Document`](https://www.nutrient.io/api/ios/documentation/pspdfkit/document) for the same backing file before the save finishes, the new instance can load stale on-disk state.

Synchronous saving (when background saving is disabled) requires the save to finish before your code continues. This makes save ordering easier to reason about, but it can block the calling thread, so it’s better suited to background processing or other noninteractive workflows.

File coordination enables Nutrient to detect this kind of conflict. Depending on the situation, Nutrient may reload the file automatically or ask the user whether to save the in-memory changes or reload the external file. These versions aren’t merged, so one side’s changes may be discarded.

## Reusing one document instance across opens

If your app shows multiple documents in a list, keep each [`Document`](https://www.nutrient.io/api/ios/documentation/pspdfkit/document) with the corresponding list item or document cache, and pass the same instance to the viewer whenever that file is opened.

This keeps in-memory edits and saving state tied to one object instead of creating a new [`Document`](https://www.nutrient.io/api/ios/documentation/pspdfkit/document) each time the file is shown. Each [`Document`](https://www.nutrient.io/api/ios/documentation/pspdfkit/document) should still be associated with only one active viewer at a time. Reuse the instance across repeated opens, not across simultaneous viewers.

For cache and data source implementation patterns, refer to [using document efficiently](https://www.nutrient.io/guides/ios/getting-started/using-document-efficiently.md).

## Summary

This table summarizes the recommended setups for working with documents, from safest to riskiest:

| Setup                                         | Recommendation                          |
| --------------------------------------------- | --------------------------------------- |
| Same [`Document`](https://www.nutrient.io/api/ios/documentation/pspdfkit/document) instance                  | Best option.                            |
| Asynchronous saving with file coordination    | Recommended for UI flows.               |
| Synchronous saving                            | Use if you can’t use file coordination. |
| Asynchronous saving without file coordination | Avoid this setup.                       |

## Related guides

- [File coordination](https://www.nutrient.io/guides/ios/features/file-coordination.md)

- [Conflict resolution](https://www.nutrient.io/guides/ios/features/conflict-resolution.md)

- [Open a PDF from a custom data provider](https://www.nutrient.io/guides/ios/features/data-providers.md)

- [Save PDFs to a custom data provider](https://www.nutrient.io/guides/ios/save-a-document/to-custom-data-provider.md)

- [Annotation and bookmark saving triggers](https://www.nutrient.io/guides/ios/annotations/annotation-and-bookmark-saving-triggers.md)

- [Using document efficiently](https://www.nutrient.io/guides/ios/getting-started/using-document-efficiently.md)
---

## Related pages

- [Advanced Carthage integration](/guides/ios/miscellaneous/advanced-carthage-integration.md)
- [Advanced CocoaPods integration](/guides/ios/miscellaneous/advanced-cocoapods-integration.md)
- [Airdrop](/guides/ios/features/airdrop.md)
- [App Transport Security](/guides/ios/pspdfkit-instant/app-transport-security.md)
- [Bitcode](/guides/ios/faq/bitcode.md)
- [Carthage integration](/guides/ios/best-practices/carthage-integration.md)
- [Framework Size](/guides/ios/faq/framework-size.md)
- [Customizing The Page Number](/guides/ios/customizing-pdf-pages/customizing-the-page-number.md)
- [Optimize PDF documents for mobile rendering on iOS](/guides/ios/miscellaneous/optimize-pdf-documents-for-mobile-rendering.md)
- [Nightly Builds](/guides/ios/best-practices/nightly-builds.md)
- [Powered By Nutrient](/guides/ios/miscellaneous/powered-by-nutrient.md)
- [Customizing the log level on iOS](/guides/ios/features/logging.md)
- [Modifying permissions in your iOS app](/guides/ios/getting-started/permissions.md)
- [iOS PDF SDK security](/guides/ios/faq/sdk-security.md)
- [Strategies For Multiple Bundle Ids](/guides/ios/faq/strategies-for-multiple-bundle-ids.md)
- [Third Party Compatibility](/guides/ios/miscellaneous/third-party-compatibility.md)
- [Transferring File Edits To A Server](/guides/ios/best-practices/transferring-file-edits-to-a-server.md)
- [Saving Data Externally](/guides/ios/memory-and-storage/saving-data-externally.md)
- [Youtube Links](/guides/ios/miscellaneous/youtube-links.md)
- [Version Numbering](/guides/ios/best-practices/version-numbering.md)
- [Manage your iOS status bar with view controllers](/guides/ios/faq/view-controller-based-status-bar-appearance.md)
- [Using Document Efficiently](/guides/ios/getting-started/using-document-efficiently.md)
- [About Memory Usage](/guides/ios/memory-and-storage/about-memory-usage.md)
- [Reduce App Size](/guides/ios/best-practices/reduce-app-size.md)

