Cascaded Windows Problem
One of the problems is that storyboards unlike xibs can include the NSWindowController
and Interface Builder doesn't serialize it right.
-initWithWindow:
, -initWithWindowNibName:
and friends set shouldCascadeWindows
to YES
.
When a NSWindowController
is loaded from a storyboard via -initWithCoder:
, shouldCascadeWindows
is NO
. (OS X 10.11)
Based on my tests, this property needs to be set in the initializer. Setting it in -[NSDocument addWindowController:]
didn't work. (OS X 10.11)
- (instancetype)initWithCoder:(NSCoder *)coder
{
self = [super initWithCoder:coder];
if (self)
{
self.shouldCascadeWindows = YES;
}
return self;
}
See rdar://47350352
Window Position Problem
Using -[NSWindowController windowFrameAutosaveName]
or -[NSWindow frameAutosaveName]
seems only to work sometimes. Randomly it uses the initial window position.
Window Size Problem
Even if the cascaded window position is set right, it never set the size to the one saved for the frame. I verified the saved frame with defaults read window.autosavename.test1
. Also before each test I run defaults delete window.autosavename.test1
for a clean state.
Workaround
Use a xib containing a empty NSWindow
and add the view controllers from the storyboard in -[NSDocument windowControllerDidLoadNib:
or -[NSDocument addWindowController:]
to the window.