Instance Method


Called by UIKit to initiate automatic saving of documents with unsaved changes.


func autosave(completionHandler: ((Bool) -> Void)? = nil)



A block with code to execute after automatic saving concludes. The block returns no value and has one parameter:


true if the autosaving operation succeeds, otherwise false.

The block is invoked on the calling queue.


UIDocument periodically invokes this method to initiate a save operation if there are unsaved changes. You should not 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 autosaveWithCompletionHandler: is invoked. However, if you call save(to:for:completionHandler:), saving of document data must occur.