• 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
Proper way to load child Window/Controller?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Proper way to load child Window/Controller?


  • Subject: Proper way to load child Window/Controller?
  • From: "Jason Sallis" <email@hidden>
  • Date: Mon, 9 Jul 2007 15:34:45 -0600

I'm working on my first semi-real Cocoa app and am having a problem.  The
app that runs as a Status Item with a menu which loads a main window.  From
that window, I want to spawn child windows.  What I currently have happening
is when the user clicks a button in the main window, I call a method which
has the following code to show the Preferences window:

[preferencesController showWindow:self];


In the init method of preferencesController, I have this code which associates the controller with the nib:


- (id)init

{

   if (self = [super initWithWindowNibName:@"Preferences"]) {

       projectService = [[ProjectService alloc] init];

       [self loadProjects];

   }

   return self;

}


This worked fine up until now when I need to access a table control from the Preferences window in my PreferencesController object. Since my controller was created outside the nib instead of being baked in, I have no outlet set to access the table. I'm sure I could get a reference to it in a really convoluted manner, but it seems like I shouldn't need to. Ideally, I should probably have the controller baked right into the nib (I think) so that I can set the outlet and go about my business as usual. So, what I tried to do was change the code to load the nib directly (with the controller baked in) instead of creating a controller directly, like so:


[NSBundle loadNibNamed:@"Preferences" owner:self]


This didn't quite work as expected. Instead of showing the window, I get a second instance of my status item for some reason. No crash, no warnings or errors. But not what I expected.


So, can anyone give me some direction on the recommended way to go about this? _______________________________________________

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


  • Follow-Ups:
    • Re: Proper way to load child Window/Controller?
      • From: Timothy Klein <email@hidden>
  • Prev by Date: Re: Modern way of getting the list of running applications?
  • Next by Date: Re: Handling Multiple Document Types
  • Previous by thread: Re: Modern way of getting the list of running applications?
  • Next by thread: Re: Proper way to load child Window/Controller?
  • Index(es):
    • Date
    • Thread