Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

larswik

macrumors 68000
Original poster
Sep 8, 2006
1,552
11
I have 2 .xib windows, the MainWindow.xib and Skills.xib. On the MainWindow.xib I have an NSPopUpButton and a NSButton to open up the second window, the Skills.xib. This code works great bellow to open the new window. The Skills window has a SkillsPreset controller that is a subclass of NSWindowController (hope I said all that right).
Code:
- (IBAction)skillWindowButton:(id)sender {
    if (!skillPrefs) {
        skillPrefs = [[SkillsPreset alloc] initWithWindowNibName:@"Skills"];
    }
    [skillPrefs showWindow:self];
}
Now the problem... On the skills window I have an NSButton 'AddSkill' and an NSTextField called 'addSkillTextField'. The goal is to type in to this TextField something like 'Sword' and then press the 'AddSkill' button and with this code bellow add it to the NSPopUpButton
Code:
- (IBAction)addSkillToCombatButton:(id)sender {
    [skillsCombatPopUpButton addItemWithTitle:[addNewSkillTextField stringValue]];
}
The NSPopUpButton on the MainWindow is binded to controller class called 'TableViewController'. In the second 'Skills' window I added an Object and assigned it to 'TableViewController' so I could connect the TextField and the NSButton to the same controller class thinking they would see each other. (I don't know if this is the right way of doing it, or if I am close).

But when I fill in the text field and press the add button it fails to add the new item to the NSPopUpButton? This worked in my last project but I only had 1 .xib window, not 2.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.