Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prevent "Resume" for my Cocoa application?

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?

like image 882
TalkingCode Avatar asked Sep 19 '11 05:09

TalkingCode


1 Answers

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.

like image 196
Peter Hosey Avatar answered Oct 23 '22 15:10

Peter Hosey