Re: A question about bindings and multiple nib files
Re: A question about bindings and multiple nib files
- Subject: Re: A question about bindings and multiple nib files
- From: Scott McMahan <email@hidden>
- Date: Tue, 9 Aug 2005 22:39:02 -0700 (PDT)
I've tried following this, but I still got nothing in
the popup button. I created a MainMenu window with a
popup button bound to the array controller and I can
see my read-in values. So the array is set up right,
I just still must not have the bindings set right.
But I've found another way to accomplish this. I
created a new array controller in the MyDocument.nib
and bound it to Shared Application with a keypath of
delegate.ranks (ranks is the array set up in the app
delegate). I then set up the popup to use this new
array controller by binding it like I would any other
intra-nib file binding between an NSArrayController
and a IB object for displaying array data.
Thanks for showing me the use of the Shared
Application binding and the delegate prefix for
getting access to MainMenu.nib. That was the key I
needed.
--- Scott Anguish <email@hidden> wrote:
>
> On Aug 8, 2005, at 12:01 AM, Scott McMahan wrote:
>
> > Ideally, I would like to read in the numerous
> to-one
> > relationships that I'm going to need at
> application
> > start up, not every time a new doc is
> open/created.
> > What I can't figure out is how to bind a pop-up
> button
> > in MyDocument.nib to an array controller in
> > MainMenu.nib.
>
> This isn't actually a bindings issue, so much
> as it is a
> multiple nibs issue.
>
> A document nib has a File's Owner of your
> NSDocument subclass.
> The MainMenu.nib has a File's Owner of the
> application instance.
>
> Some class that is imported in your
> MainMenu.nib is going to
> need to have an outlet that is connected to the
> arraycontroller in
> your MainMenu.nib
> The easiest way to do this, and something
> you'll quite possibly
> need at some point in your application development,
> is a class that
> acts as an Application Delegate.
>
> So, make a new class, I like
> AppDelegate(.h|.m). it inherits
> from NSObject usually. Declare the array controller
> that holds the
> common information
>
>
> The .h will need to have the one line below added
>
> @interface AppDelegate:NSObject
> {
> IBOutlet NSArrayController
> *commonArrayController;
> }
>
> @end
>
> Next, import that AppDelegate.h into your
> MainMenu.nib file. (drag
> the .h from Xcode to the MainMenu.nib window in IB)
> Instantiate an instance of that (select AppDelegate
> in the Classes
> tab, and then control click (right click) and select
> instantiate
> switch to the instances tab and control drag from
> the File's Owner to
> the AppDelegate icon
> make it the delegate
>
>
> Now, open your document.nib file
>
> You can now link your pop up in this nib to the
> array controller
> using the following path
>
> select your popup or whatever in your document nib
>
> bind the content to Application with the keypath
> delegate.commonArrayController
>
>
> of course you could create the binding
> programmatically, but you'll
> still need an outlet in the mainnib that is
> connected to the
> arraycontroller.. so this is just as easy...
>
>
> --
> "William Cheeseman ... is said not to be a doofus in
> real life." -
> Roger Ebert, Chicago Sun-Times Online
>
> Scott Anguish
> email@hidden
>
>
>
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden