Contents

hasUnsavedChanges

A Boolean value that indicates whether the document has any unsaved changes.

Declaration

var hasUnsavedChanges: Bool { get }

Return Value

true if the document has unsaved changes, otherwise false.

Discussion

The default implementation of autosave(completionHandler:) initiates a save if this property returns true. Typical subclasses don’t need to override hasUnsavedChanges. To implement change tracking, they should instead use an UndoManager object (assigned to undoManager) to register changes or call updateChangeCount(_:) every time the user makes a change; UIKit then automatically determines whether there are unsaved changes.

See Also

Tracking changes and autosaving