开发者

Keep state of complete application once quit

I am having trouble keeping the state of my Mac OS X app (running on Lion) when it is closed - it currently only has an NSTextView in the window and I want to keep the state of the window size and the text that'开发者_StackOverflows actually in my NSTextView along with its formatting for when the application next loads up.

I was therefore wondering if anyone could give me a pointer (ha, get it - pointer?) as to how to go about keeping the state of my application so it's the same when the application is opened again once quit. Thanks in advanced.


What's wrong with just storing your information in the user defaults using the NSUserDefaults class, and then loading those settings back in when the application launches?

In the XIB, you can set your window to "not visible at startup". You can then implement applicationDidFinishLaunching in your AppDelegate, do the appropriate setup there - the final line of code in that method would be to make the app's window visible. This way you avoid any user confusion and the app will look snappy and responsive, i.e. until the app is fully loaded nothing becomes visible.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜