7

I love the new "Resume" feature in Lion. After a restart window size and position is exactly how you left it. But during development this is a bit annoying. If I resize a window in the Interface Builder and restart my application it doesn't have the new size but the old size.

In the past you had to set the AUTOSAVE property to get this kind of behavior but with Resume it all happens automatically. Can I disable resume for my application somehow?

TalkingCode
  • 13,407
  • 27
  • 102
  • 147

1 Answers1

12

Yes. As documented in the Lion AppKit release notes, you can set the ApplePersistenceIgnoreState user default for your application. (The docs imply that the value isn't significant; it just needs to be set to something.)

An easy way to do this for debug runs only, while preserving the state restoration feature when you use your app normally, is to set it in Xcode. In your scheme's Run action, set a command-line argument for -ApplePersistenceIgnoreState, and, immediately after it, another one with the value (e.g., YES). This makes use of AppKit's feature of reading user defaults from the command-line.

Peter Hosey
  • 95,783
  • 15
  • 211
  • 370
  • What's the best way to disable resume for the production environment as well? – aneuryzm Jan 02 '12 at 08:47
  • @Patrick: Probably to register the default value for that key as `NO`. You could then offer a checkbox in your Preferences panel so users who like resume can re-enable it. – Peter Hosey Jan 02 '12 at 18:01
  • The link redirects to the most recent AppKit release notes. On https://developer.apple.com/library/prerelease/mac/releasenotes/AppKit/RN-AppKitOlderNotes/ an in-page search will tell you that "When the user default ApplePersistenceIgnoreState is defined, existing restorable state and Untitled documents are ignored. New restorable state and Untitled document autosaves are redirected to a temporary directory, whose path will be logged to the console. This user default is intended for automated tests that want to start with a clean environment, and for debugging." – Elise van Looij Jan 26 '16 at 17:24