2

I have a macOS and iOS app, based on NSDocument and UIDocument respectively.

They synchronize their documents via iCloud Drive.

I noticed that NSDocument.revert(toContentsOf:ofType:) is called on the Mac when a document is merely opened in the iOS app:

  1. Open the Mac app and open a document in iCloud Drive
  2. Open the same document with the iOS app
  3. NSDocument.revert(toContentsOf:ofType:) is called in the Mac app causing it to reload its contents unnecessarily, since the file contents have not been changed.

I observed that the file's content access date and attribute modification dates change upon opening (NSURLAttributeModificationDateKey, NSURLContentAccessDateKey).

The documentation says:

NSDocument.revert(toContentsOf:ofType:)

Discards all unsaved document modifications and replaces the document’s contents by reading a file or file package located by a URL of a specified type.

It seems quite unnecessary to discard all unsaved changes and replacing the document's contents when the contents did not change.

Is it intended behavior to revert a document's contents when only the file attributes change or did I miss anything?

Mark
  • 6,647
  • 1
  • 45
  • 88

0 Answers0