Type Property

autosavesInPlace

Returns whether the receiver supports autosaving in place.

Declaration

class var autosavesInPlace: Bool { get }

Return Value

true if the receiver supports autosaving in place; false otherwise.

Discussion

The default implementation of this method returns false. You can override it and return true to declare that your subclass of NSDocument can do autosaving in place. You should not invoke this method to find out whether autosaving in place is actually being done at any particular moment. You should instead use the NSDocument.SaveOperationType parameter that the system passes to your overrides of save and write methods.

AppKit invokes this method at a variety of times, and not always on the main thread. For example, autosave(withImplicitCancellability:completionHandler:) invokes this method as part of determining whether the autosaving will be performed in place (autosaveInPlaceOperation) or in a separate autosave directory (autosaveElsewhereOperation). As another example, the canClose(withDelegate:shouldClose:contextInfo:) method and the NSDocumentController machinery for handling unsaved changes at app termination time both invoke this method as part of determining whether alerts about unsaved changes should be presented to the user.

See Also

Autosaving

func checkAutosavingSafety()

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

func scheduleAutosaving()

Schedules periodic autosaving for the purpose of crash protection.

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 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.