Re: [NSApp mainWindow] weirdness
Re: [NSApp mainWindow] weirdness
- Subject: Re: [NSApp mainWindow] weirdness
- From: email@hidden (Simon Fraser)
- Date: Mon, 01 Jul 2002 20:20:00 -0700
Shawn Erickson wrote:
On Monday, July 1, 2002, at 07:34 PM, Simon Fraser wrote:
When does NSApplication set up its 'mainWindow'? I'm seeing cases
where we've got a window on the screen, but [NSApp mainWindow] is
still returning null (this is often at application startup time).
Some time later, [NSApp mainWindow] will correctly return this window.
Does [NSApp mainWindow] only get set after we've been back through
the main event loop after creating the window? Or is there some
other timing wierdness involved?
From the docs for mainWindow...
"Returns the main window. This method returns nil if there is no main
window, if the application's nib file hasn't finished loading, if the
main window belongs to another application, or if the application is
hidden."
In this case it sounds like you are attempting to access the main window
before nib has finished loading.
In your apps delegate implement
applicationDidFinishLaunching:(NSNotification*) to know when your app is
fully loaded so you can do an final initialization needed.
applicationDidFinishLaunching is exactly the place where
[NSApp mainWindow] is lying to me. I've also seen [NSApp mainWindow]
return null when handling Apple Events (oddly, from just some Carbon
apps) long after startup.
Simon
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.