Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

macos - 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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...