Instance Method


Schedules periodic autosaving for the purpose of crash protection.


func scheduleAutosaving()


The default implementation of this method checks to see if autosaving is turned on and, if so and if [self hasUnautosavedChanges] returns true, schedules an NSTimer to invoke autosave(withDelegate:didAutosave:contextInfo:) in the future. If [self hasUnautosavedChanges] returns false it unschedules any previously scheduled timer. It takes care not to cause autosave(withDelegate:didAutosave:contextInfo:) to be invoked before a previous invocation caused by it has finished. The exact timings it uses are complicated and subject to change in future releases of macOS. You can override this method to control when exactly periodic autosaving happens. It is invoked by updateChangeCount(_:) and updateChangeCount(withToken:for:).

See Also


func checkAutosavingSafety()

Returns a Boolean value indicating whether it is probably safe to autosave document changes.

var hasUnautosavedChanges: Bool

A Boolean value indicating whether the document has changes that have not been autosaved.

func autosave(withImplicitCancellability: Bool, completionHandler: (Error?) -> Void)

Autosaves the document’s contents at an appropriate location if it needs autosaving.

class var autosavesInPlace: Bool

Returns whether the receiver supports autosaving in place.

class var autosavesDrafts: Bool

Returns whether the receiving subclass of NSDocument supports autosaving of drafts.

class var preservesVersions: Bool

Returns whether the receiving subclass of NSDocument supports Versions.

func browseVersions(Any?)

Opens the Versions browser in the document’s main window.

var autosavingFileType: String?

Returns the document type that should be used for an autosave operation.

var autosavingIsImplicitlyCancellable: Bool

A Boolean value indicating whether autosaving is happening now but could be safely cancelled.

var autosavedContentsFileURL: URL?

The location of the most recently autosaved document contents.