非ドキュメントベースのアプリケーションで、Swift に NSWindowRestoration プロトコルを実装してみました。ただし、restoreWindowWithIdentifier
アプリケーションの起動時にメソッドが呼び出されることはありません。誰かが私の間違いを指摘できますか?
コードのサブセットを次に示します (正常にコンパイルおよび実行されます)。
class AppDelegate: NSObject, NSApplicationDelegate, NSWindowRestoration {
var windowController : MyWindowController?
func applicationDidFinishLaunching(aNotification: NSNotification?) {
windowController = MyWindowController(windowNibName:"ImageSequenceView")
}
class func restoreWindowWithIdentifier(identifier: String!, state: NSCoder!, completionHandler: ((NSWindow!,NSError!) -> Void)!) {
NSLog("restoreWindowWithIdentifier: \(identifier), state: \(state)")
}
}
class MyWindowController: NSWindowController {
override func windowDidLoad() {
super.windowDidLoad();
window.restorationClass = AppDelegate.self
}
}
前もって感謝します!