Instance Property

hasUnsavedChanges

Returns 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 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(UIDocumentChangeKind)

Update the change counter by indicating the kind of change.

var undoManager: UndoManager!

The undo manager for the document.

func changeCountToken(for: UIDocumentSaveOperation)

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

func updateChangeCount(withToken: Any, for: UIDocumentSaveOperation)

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.