Search code examples
objective-cxcodemacoscocoansdocument

NSDocument-based app window position


My Xcode NSDocument-based app contains a floating panel. On each launch of the app the default doc window and panel appear in their previous locations on the screen. However, if I save a document and quit the app then double click the saved file, the document window is positioned at the same origin as the panel.

Turning off cascading gets around the problem but of course I lose cascading.

A minimum Xcode example showing the issue can be downloaded here.

  1. Run the example project.
  2. Do a File/Save.
  3. Quit the app. << important
  4. Double click the saved file.

Any help appreciated.


Solution

  • I knew it had something to do with document windows cascading from the panel. Adding this to the panel controller seems to have fixed it

    - (void)windowDidLoad { [super windowDidLoad]; [self setShouldCascadeWindows:NO]; }