additionalContent(for:)
Handles writing non-Core Data content to the additional content directory in the document’s file package.
Declaration
func additionalContent(for absoluteURL: URL) throws -> AnyParameters
- absoluteURL:
The URL for the additional content directory in the document’s file package.
Return Value
An object that contains the additional content for the document at absoluteURL, or nil if there is a problem.
Discussion
You override this method to perform to manage non-Core Data content to be stored in the additional content directory in the document’s file package.
If you implement this method, it’s invoked automatically by contents(forType:). The returned object is passed to writeAdditionalContent(_:to:originalContentsURL:).
There’s no need to invoke super’s implementation.
Special considerations
A return value of nil indicates an error condition. To avoid generating an exception, you must return a value from this method. If it isn’t always the case that there will be additional content, you should return a sentinel value (for example, an NSNull instance) that you check for in writeAdditionalContent(_:to:originalContentsURL:).
The object returned from this method is passed to writeAdditionalContent(_:to:originalContentsURL:). Because writeAdditionalContent(_:to:originalContentsURL:) is executed on a different thread, you must ensure that the object you return is thread-safe. For example, you might return an NSData object containing an archive of the state you want to capture.
Additional content isn’t supported on iCloud.