作者copyshaft (冒烟的洋葱)
看板MacDev
标题[问题] Saving a NSWindow's position into the User Defaults
时间Wed Aug 11 11:23:19 2010
Hi,
根据Apple Developer的Window Programming Guide手册 page 35
NSWindow *window = // the window in question
// Tell the controller to not cascade its windows.
[[window windowController] setShouldCascadeWindows:NO];
// Specify the autosave name for the window.
[window setFrameAutosaveName:[window representedFilename]];
文件连结
http://bit.ly/9NFMMF
我实作了以下的测试专案
AppController.h
http://gist.github.com/518367
AppController.m
http://gist.github.com/518368
(inherit from NSWindowController)
MyPanelController.h
http://gist.github.com/518369
MyPanelController.m
http://gist.github.com/518375
问题:
1. [window representedFilename] 回传的NSString物件是nil
到底他要represent的是什麽file?
我要负责create什麽东西去先做setRepresentedFilename:吗
官方的叙述不是很能理解.
The path to the file of the window’s represented file.
2. 以自定字串(见程式码)取代 [window representedFilename]
在init 呼叫 setFrameAutosaveName 回传BOOL一直是NO
Note: 在Interface Builder的attribute inspector
针对该Window/Panel 可直接设定autosave name。
不过透过以上程式做设定却不成功。
恳请版上的朋友能指点我理解上的盲点和范例程式上的错误。
感激不尽。
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 123.204.186.221