Re: How to connect to menu items from another Nib?
Re: How to connect to menu items from another Nib?
- Subject: Re: How to connect to menu items from another Nib?
- From: Matt Neuburg <email@hidden>
- Date: Sat, 31 Aug 2002 04:10:59 -0700
On Sat, 31 Aug 2002 10:12:14 +0800, John McGruer <email@hidden> said:
>
I want to make a connection to some NSMenuItem objects (in order to change
>
their titles etc), but from another Nib - not the MainMenu.nib the menus are
>
contained in. However, I can9t seem to do this easily in IB. The only way I
>
have been successful is programmatically by using [NSApp maninMenu] and then
>
referencing items from this. Is there a more direct way to accomplish the
>
connection in IB? In case I9m not being clear, I9d like to be able to
>
connect using IBOutlet statements and control-connecting in IB.
This has been answered many times - on this list (check the archives), in
the various books about Cocoa, in the SimpleMultiWindow example that's on
your hard disk, and so forth. Basically the answer is: no, you can't draw a
connection between one nib and another, so you have to pass through some
object to which you have access within the nib. The nib contains two proxy
objects - the file's owner and the first responder - that get you out of
the nib and into the larger world of your program's code. They - especially
the file's owner - are the primary mediators here. The file's owner can
communicate with the rest of your objects through the usual means. So,
indeed, can any object instantiated inside the nib (for example such an
object could throw out a notification and hope someone catches it), but the
file's owner has the advantage that it is initialized outside the nib and
therefore whoever initializes it can tell it all about other objects it
needs to know about. For added elegance, if (as is usual) the file's owner
is an NSWindowController, it gets a message when the window loads and can
hook things in the nib to things outside it. Use of the full document
architecture adds even more power. Finally all objects have access to NSApp
and its delegate. m.
--
matt neuburg, phd = email@hidden,
http://www.tidbits.com/matt
pantes anthropoi tou eidenai oregontai phusei
Subscribe to TidBITS! It's free and smart.
http://www.tidbits.com/
_______________________________________________
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.