[問題] Saving a NSWindow's position into the User Defaults
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
MacDev 近期熱門文章
PTT數位生活區 即時熱門文章