autosave(completionHandler:)
Initiates automatic saving of documents with unsaved changes.
Declaration
func autosave(completionHandler: (@Sendable (Bool) -> Void)? = nil)func autosave() async -> BoolParameters
Discussion
UIDocument periodically invokes this method to initiate a save operation if there are unsaved changes. You shouldn’t call this method directly. Subclasses can override it if they want to do special things with autosaving. The default implementation of this method invokes the hasUnsavedChanges method and, if that returns true, it invokes the save(to:for:completionHandler:) method.
This method should only be invoked for period-based saves. You may invoke it with the success parameter of the completion-handler parameter set to false and return; this makes it safe to not actually save when autosave(completionHandler:) is invoked. However, if you call save(to:for:completionHandler:), saving of document data must occur.