Re: Can 2 nib share a same custom class instance?
Re: Can 2 nib share a same custom class instance?
- Subject: Re: Can 2 nib share a same custom class instance?
- From: "Kyle Sluder" <email@hidden>
- Date: Tue, 18 Nov 2008 18:22:07 -0500
On Tue, Nov 18, 2008 at 5:43 PM, Jean-Nicolas Jolivet
<email@hidden> wrote:
> I have a custom window controller (let's call it CustomWindowController) to
> manage a custom window... this is contained in a separate nib file (i.e. not
> in my MainMenu.nib)
Typically this isn't what you want to do. You'll usually create the
window controller from code (external to any nib) and use it as the
owner of a nib that contains the window you want it to control.
> In that window's nib file, the File Owner is set to that
> CustomWindowController class so that my class can communicate with my
> window...
Good.
> Now here comes the tricky part: I want a menu item from the app's main menu
> (located in MainMenu.nib) to ALSO be able to perform this action (the same
> performActionClicked: thats located in my CustomWindowController)....
Use the responder chain.
> Is there a way that both nib files can "share" the same instance of my
> CustomWindowController???
If you can reach it from File's Owner, you can do what you want, but
as I said above this is a typical use of the responder chain. Though
depending on your situation an NSWindowController subclass might not
be the appropriate place for it; it might be an NSDocument subclass or
your NSApplication's delegate.
--Kyle Sluder
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden