• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: A question about bindings and multiple nib files
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: A question about bindings and multiple nib files


  • Subject: Re: A question about bindings and multiple nib files
  • From: Scott Anguish <email@hidden>
  • Date: Mon, 8 Aug 2005 01:27:46 -0400


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 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
  • Follow-Ups:
    • Re: A question about bindings and multiple nib files
      • From: Scott McMahan <email@hidden>
References: 
 >A question about bindings and multiple nib files (From: Scott McMahan <email@hidden>)

  • Prev by Date: A question about bindings and multiple nib files
  • Next by Date: ANN: ObjectiveCLIPS Available
  • Previous by thread: A question about bindings and multiple nib files
  • Next by thread: Re: A question about bindings and multiple nib files
  • Index(es):
    • Date
    • Thread