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

# restoreState(with:)

Restores the interface-related state of the document.

```
func restoreState(with coder: NSCoder)
```

## Parameters

`coder`

The coder object to use to restore the document’s interface-related state.

## Discussion

This method is part of the window restoration system and is called at launch time to restore the window-related state of your document object. The default implementation restores some basic information about the document. If you override this method, you must call `super` at some point in your implementation.

Subclasses can override this method and use it to restore the document-related information that was saved in the [`encodeRestorableState(with:)`](/documentation/AppKit/NSDocument/encodeRestorableState(with:)) method. You can also use this method to reconfigure the document (or its associated window controller and window) to their previous appearance.

> Note:
> If the user’s computer is configured to close all windows when an app quits, the system automatically removes any preserved state as part of that process. As a result, the system doesn’t call `restoreState(with:)` the next time your app launches.

For information about using a coder object to read data from an archive, see <doc://com.apple.documentation/documentation/Foundation/encoding-and-decoding-custom-types>.

---

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)