<!--
{
  "availability" : [
    "macOS: 10.7.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSWindowDelegate/window(_:willEncodeRestorableState:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(pl)NSWindowDelegate(im)window:willEncodeRestorableState:"
  },
  "title" : "window(_:willEncodeRestorableState:)"
}
-->

# window(_:willEncodeRestorableState:)

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

```
@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

This method is called during the window’s [`encodeRestorableState(with:)`](/documentation/AppKit/NSResponder/encodeRestorableState(with:)) method.

---

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)