Instance Property


Returns whether the document has any unsaved changes.


var hasUnsavedChanges: Bool { get }

Return Value

true if the document has unsaved changes, otherwise false.


The default implementation of autosave(completionHandler:) initiates a save if this method returns true. Typical subclasses do not need to override the hasUnsavedChanges method. 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

func updateChangeCount(UIDocument.ChangeKind)

Update the change counter by indicating the kind of change.

var undoManager: UndoManager!

The undo manager for the document.

func changeCountToken(for: UIDocument.SaveOperation) -> Any

Overridden to return a change token for a specific save operation.

func updateChangeCount(withToken: Any, for: UIDocument.SaveOperation)

Overridden to update the change count with reference to a change-count token passed in by UIKit.

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

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