1

I am having a difficult time implementing this new "feature" of Mac OS X 10.7. For the most part, my application works without my having to do anything. Files reopen on launch as expected. If the file is deleted however, my application opens to nothing and a new, blank document needs to be opened via the File menu.

So, what I have done so far is when a new window is created, I call

[myWindow setRestorationClass:(Class < NSWindowRestoration >)self];

with self being my NSDocument class.

Since restoreWindowWithIdentifier:state:completionHandler: is a class method I can't call my windowController creation method [self makeWindowControllers] from within it nor could I call [self initWithType:error] to create a new document if the one being sent has been deleted. How does one tell if the document being sent has been deleted from within this method?

I've read all I can find on Apple's site and elsewhere on this issue and am getting nowhere. Realize my core understanding of this is lacking and I apologize for that. I appreciate any help. Thank you.

Arthur
  • 598
  • 1
  • 7
  • 18
  • I have the same behaviour with my app. AFAIK the user has to choose File -> New to open a new main window when the original file was deleted, or open another file with File -> Open. For my app this works "out of the box".... – Roger Nov 30 '11 at 21:08
  • I disabled the restoration feature by unchecking my window's restorable state in IB. However, now when the program relaunches a new untitled document is not opened as what used to happen. Frustrating. – Scott Henderson Dec 01 '11 at 17:40

1 Answers1

1

As far as I understand the problem I think you have to enable in your app delegate

- (BOOL)applicationShouldOpenUntitledFile:(NSApplication *)sender;
{
    return YES;
}

Did you try that?

Stephan
  • 4,263
  • 2
  • 24
  • 33