---
title: hasUnsavedChanges
framework: uikit
role: symbol
role_heading: Instance Property
path: uikit/uidocument/hasunsavedchanges
---

# hasUnsavedChanges

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

## Declaration

```swift
var hasUnsavedChanges: Bool { get }
```

## Return Value

Return Value true if the document has unsaved changes, otherwise false.

## Discussion

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

- [updateChangeCount(_:)](uikit/uidocument/updatechangecount(_:).md)
- [undoManager](uikit/uidocument/undomanager.md)
- [changeCountToken(for:)](uikit/uidocument/changecounttoken(for:).md)
- [updateChangeCount(withToken:for:)](uikit/uidocument/updatechangecount(withtoken:for:).md)
- [autosave(completionHandler:)](uikit/uidocument/autosave(completionhandler:).md)
