I tried implementing the NSWindowRestoration protocol in Swift, in a non-document-based application. However, the method restoreWindowWithIdentifier
is never called at application launch. Can anyone point out my mistake?
Here is a subset of the code (which compiles and runs fine):
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
}
}
Thanks in advance!
super.windowDidLoad()
and setting thewindow.restorationClass
. – Goldiself.dynamicType
and make sure my system preferences are set to restore windowsrestoreWindowWithIdentifier
on my class is called. – Disappearance