Я попытался реализовать протокол NSWindowRestoration в Swift в приложении, не основанном на документах. Однако метод 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
}
}
Заранее спасибо!
super.windowDidLoad()
и установитеwindow.restorationClass
. - person Erik   schedule 10.06.2014self.dynamicType
и удостоверяюсь, что мои системные настройки настроены на восстановление окон, вызываетсяrestoreWindowWithIdentifier
в моем классе. - person Bjorn   schedule 13.01.2015