I am using SDK 10.8.
I am subclassing NSPersistentDocument
(but the question might interest people sublassing NSDocument
) and I want to deactivate the window restoration. So far, here is what I have done :
-(void)restoreStateWithCoder:(NSCoder *)coder
{
NSLog(@"No 1") ;
}
-(void)restoreDocumentWindowWithIdentifier:(NSString *)identifier
state:(NSCoder *)state
completionHandler:(void (^)(NSWindow *, NSError *))completionHandler
{
NSLog(@"No 2") ;
}
The problem is that when I try in my application to create a new document, no window is shown.
What is the proper way to desactivate the window restoration ?
This function of window restoration makes my app unlaunchable, for instance after a crash (or I click stop in xcode). I don't want the users of my app to face the same problem and be unable to launch anymore the app.
That should only be true if your stored state is corrupt or you've changed the keys you store it under.
In normal circumstances, state restoration exists to save user data (that they haven't manually saved) in the event of a crash—your users will want it to be there when the app crashes on them.
For debugging purposes, you can disable state restoration in your Xcode scheme: