Instance Method

writeAdditionalContent(_:to:originalContentsURL:)

Handles writing non-Core Data content to the document’s file package.

Declaration

func writeAdditionalContent(_ content: Any, to absoluteURL: URL, originalContentsURL absoluteOriginalContentsURL: URL?) throws

Parameters

content

An object that represents the additional content for the document.

This is the object returned from additionalContent(for:).

absoluteURL

The URL to which to write the additional content.

absoluteOriginalContentsURL

The current URL of the document that is being saved.

error

Upon return, if a problem occurs, contains an error object that describes the problem.

Return Value

true if the write operation is successful, otherwise false.

Discussion

You override this method to perform to write non-Core Data content in the additional content directory in the document’s file package. There are several issues to consider:

  • You should typically implement this method only if you have also implemented additionalContent(for:).

  • Because this method is executed asynchronously, it is possible that the document’s state may be different from that at which the save operation was initiated. If you need to capture the document state at save time, you should do so in additionalContent(for:).

  • If you implement this method, it is invoked automatically by writeContents(_:andAttributes:safelyTo:for:).

  • There is no need to invoke super’s implementation.

Special Considerations

Additional content is not supported on iCloud.

See Also

Customizing Read and Write Operations

func readAdditionalContent(from: URL)

Handles reading non-Core Data content in the additional content directory in the document’s file package.

func additionalContent(for: URL) -> Any

Handles writing non-Core Data content to the additional content directory in the document’s file package.