Re: [NEWBIE] App with no initial document?
Re: [NEWBIE] App with no initial document?
- Subject: Re: [NEWBIE] App with no initial document?
- From: Kurt Revis <email@hidden>
- Date: Sun, 26 Aug 2001 15:26:09 -0700
On Sunday, August 26, 2001, at 03:05 PM, Eric Smith wrote:
Unfortunately, my application insists on starting up with an untitled
document. How do I change this behaviour? I would either like a) to
start with just a menu-bar, or b) to start with a File Open dialog.
Since it doesn't seem to be kosher to subclass NSApplication, I'll
hazard a guess that I have to add a delegate of some sort, and that it
should implement either applicationOpenUntitledFile or
applicationShouldOpenUntitledFile (which one?).
The latter. Think of it as a conversation: The NSApplication asks its
delegate "should I open an untitled window?". If the delegate answers
NO, then the app doesn't do anything. If YES, then the NSApplication
goes on and calls applicationOpenUntitledFile.
(If you want to start with a File Open dialog, you should probably do
that in applicationDidFinishLaunching.)
But it looks like delegates have to be hooked up in a .nib file, and
the only obvious possibility is MainMenu.nib. Should I really be
hooking up the delegate in MainMenu.nib?
You have the right idea. Don't worry about the fact that the nib is
called MainMenu.nib -- it often ends up containing other things besides
just menus. (You could change the name to something like
ApplicationGlobalObjects.nib, if you really wanted to.)
So tell IB about your application delegate class, and instantiate it in
MainMenu.nib. Note that the File's Owner is the NSApplication, so
connect the File's Owner's "delegate" outlet to your delegate. That's it.
--
Kurt Revis
email@hidden