<!--
{
  "availability" : [
    "iOS: 5.0.0 -",
    "iPadOS: 5.0.0 -",
    "macCatalyst: 13.1.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UIDocument/hasUnsavedChanges",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Property",
  "symbol" : {
    "kind" : "Instance Property",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)UIDocument(py)hasUnsavedChanges"
  },
  "title" : "hasUnsavedChanges"
}
-->

# hasUnsavedChanges

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

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

## Return Value

<doc://com.apple.documentation/documentation/Swift/true> if the document has unsaved changes, otherwise <doc://com.apple.documentation/documentation/Swift/false>.

## Discussion

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

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)