<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSDocument/revertToSaved(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSDocument(im)revertDocumentToSaved:"
  },
  "title" : "revertToSaved(_:)"
}
-->

# revertToSaved(_:)

The action of the File menu item Revert in a document-based app.

```
@IBAction func revertToSaved(_ sender: Any?)
```

## Parameters

`sender`

The control sending the message.

## Discussion

The default implementation of this method presents an alert dialog giving the user the opportunity to cancel the operation. If the user chooses to continue, the method ensures that any editor registered using the Cocoa Bindings `NSEditorRegistration` informal protocol has discarded its changes and then invokes [`revert(toContentsOf:ofType:)`](/documentation/AppKit/NSDocument/revert(toContentsOf:ofType:)). If that returns <doc://com.apple.documentation/documentation/Swift/false>, the method presents the error to the user in an document-modal alert dialog.

## See Also

[`-  updateChangeCount:`](/documentation/AppKit/NSDocument/updateChangeCount(_:))

Updates the receiver’s change count according to the given change type.



---

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)