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

# extendStateRestoration()

Allows an app to extend its state restoration period.

```
func extendStateRestoration()
```

## Discussion

This method allows an app to extend the state restoration period beyond the usual. For example, the app crashes before state restoration is complete, then it may offer to discard restorable state on the next launch.

If a window has some state that may take a long time to restore, such as a web page, you may use this method and methods to [`completeStateRestoration()`](/documentation/AppKit/NSApplication/completeStateRestoration()) to extend the period of this crash protection beyond the default.

You call `extendStateRestoration` within your implementation of [`restoreWindow(withIdentifier:state:completionHandler:)`](/documentation/AppKit/NSApplication/restoreWindow(withIdentifier:state:completionHandler:)).  You would then call [`completeStateRestoration()`](/documentation/AppKit/NSApplication/completeStateRestoration()) some time after the window is fully restored.  If the app crashes in the interim, then it may offer to discard restorable state on the next launch.

The `extendStateRestoration` and [`completeStateRestoration()`](/documentation/AppKit/NSApplication/completeStateRestoration()) methods act as a counter. Each call to `extendStateRestoration` increments the counter, and must be matched with a corresponding call to [`completeStateRestoration()`](/documentation/AppKit/NSApplication/completeStateRestoration()) which decrements it.  When the counter reaches zero, the app is considered to have been fully restored, and any further calls are silently ignored.

This method is thread safe.

---

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)