Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get rid of "Do you want to try to reopen its windows again?" dialogs

Tags:

xcode

cocoa

I'm building a Cocoa application with Xcode. I have to force-kill my app for unrelated reasons, and every time I do I get this popup:

The last time you opened MyApp, it unexpectedly quit while reopening windows. Do you want to try to reopen its windows again?

If you choose not to reopen windows, you may have to open and position the windows yourself.

[Don't Reopen] [Reopen]

What is this system called and how can I disable it for my application?

like image 462
a paid nerd Avatar asked Sep 29 '22 04:09

a paid nerd


1 Answers

This is Cocoa's automatic state restoration in action. You can suppress it when your app is launched under Xcode by editing your active scheme, choosing the Run action, and checking "Launch application without state restoration".

Disabling state restoration in your app's scheme

Note: Disabling this will also disable automatically-reopening documents that were opened previously, which can be a pain for testing a document-based application, since you'll have to re-open the doc manually each time you run it. This also only disables state restoration while being run under Xcode under that particular scheme.

like image 95
Joshua Nozzi Avatar answered Oct 12 '22 23:10

Joshua Nozzi