On Mar 20, 2015, at 3:54 AM, Bill Cheeseman <wjcheese...@gmail.com> wrote:

> My launch sequence goes like this: My Info.plist file designates MainMenu as 
> the application's principal nib file. My MainMenu nib file names 
> NSApplication as file's owner, it contains the menu bar and my archived 
> appDelegate object, and it connects appDelegate as NSApplication's delegate. 
> MainMenu.xib does not contain a window object, as Ken has recommended.  At 
> launch, MainMenu is loaded as the designated principal nib file, its 
> appDelegate archive is unarchived, and NSApplication calls appDelegate's 
> implementation of the -applicationDidFinishLaunching: delegate method. My 
> implementation of the delgate method then explicitly creates my window 
> controller object and initializes it using 
> -initWithWindowNibName:"MainWindow". This is what loads my MainWindow nib 
> file and calls its -windowDidLoad method.

Nope.  That's not enough.  A window controller does not load the NIB (nor call 
-windowDidLoad) just because it's been allocated and initialized with a NIB 
name.  Something has to be requesting the window.

Again, I ask you to read the docs for NSWindowController, in particular the 
-window method, and reconcile that with how you think it works.  If just 
initializing the window controller with a NIB name was sufficient to load it, 
why would that start with "If the window has not yet been loaded, this method 
attempts to load the window’s nib…"?

> When the nib file loads, somebody notices that MainWindow.xib's Visible at 
> Launch setting is set, so it immediately shows the window. My code requires 
> no explicit reference to the window property and no call to -showWindow or 
> -makeKeyAndOrderFront: to make the window appear.

It must.

> The Visible at Launch setting in the MainWindow nib file is sufficient by 
> itself, which is the only point I was trying to make.

Visible at Launch is sufficient to make the window show once the NIB has been 
loaded, but you're missing something that is loading the NIB.

Put a breakpoint in -windowDidLoad and look at the stack trace.  Or log 
[NSThread callStackSymbols] in -windowDidLoad.  You'll find what's doing it.

Regards,
Ken


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to