---
title: "window(_:willEncodeRestorableState:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nswindowdelegate/window(_:willencoderestorablestate:)"
---

# window(_:willEncodeRestorableState:)

Tells the delegate the window is about to add its restorable state to a given archiver.

## Declaration

```swift
@MainActor optional func window(_ window: NSWindow, willEncodeRestorableState state: NSCoder)
```

## Parameters

- `window`: The window adding its restorable state to an archive.
- `state`: The coder creating the archive.

## Discussion

Discussion This method is called during the window’s encodeRestorableState(with:) method.

## See Also

### Managing Restorable State

- [window(_:didDecodeRestorableState:)](appkit/nswindowdelegate/window(_:diddecoderestorablestate:).md)
