---
title: "restoreState(with:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nsresponder/restorestate(with:)"
---

# restoreState(with:)

Restores the interface-related state of the responder.

## Declaration

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

## Parameters

- `coder`: The coder object to use to restore the responder’s interface-related state.

## Discussion

Discussion This method is part of the window restoration system and is called at launch time to restore the visual state of your responder object. The default implementation does nothing but specific subclasses (such as NSView and NSWindow) override it and save important state information. Therefore, if you override this method, you should always call super at some point in your implementation. Subclasses can override this method and use it to restore any information that was saved in the encodeRestorableState(with:) method. You can also use this method to reconfigure the responder to its 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 Encoding and Decoding Custom Types.

## See Also

### Handling Window Restoration

- [allowedClasses(forRestorableStateKeyPath:)](appkit/nsresponder/allowedclasses(forrestorablestatekeypath:).md)
- [encodeRestorableState(with:)](appkit/nsresponder/encoderestorablestate(with:).md)
- [encodeRestorableState(with:backgroundQueue:)](appkit/nsresponder/encoderestorablestate(with:backgroundqueue:).md)
- [restorableStateKeyPaths](appkit/nsresponder/restorablestatekeypaths.md)
- [invalidateRestorableState()](appkit/nsresponder/invalidaterestorablestate().md)
