0

I need to use a custom view (NSView *mainContent) and swap the view with a different nib based on the user selection from a NSPopUpButton. The IBAction method for the popup button looks like this:

- (IBAction)menuSelected:(NSPopUpButton *)sender {

NSInteger index = [sender indexOfSelectedItem];
NSLog(@"Selected button index is %ld", index);

[dynamicTitle.cell setTitle:[self returnSectionTitle:index]];
NSLog(@"%@", dynamicTitle.stringValue);

switch (index) {
    case 0:
        Sect1 = [[Sect1_View alloc] initWithNibName:@"Sect1_View" bundle:nil];
        maincontent = Sect1.view;
        [maincontent release];
        break;
    case 1:
    Sect2 = [[Sect2_View alloc] initWithNibName:@"Sect2_View" bundle:nil];


        break;
    case 2:
    Sect3a = [[Sect3a_View alloc] initWithNibName:@"Sect3a_View" bundle:nil];

        break;
    case 3:
    Sect3b = [[Sect3b_View alloc] initWithNibName:@"Sect3b_View" bundle:nil];    

        break;
    case 4:
    Sect3c = [[Sect3c_View alloc] initWithNibName:@"Sect3c_View" bundle:nil];    

        break;
    case 5:
    Sect4 = [[Sect4_View alloc] initWithNibName:@"Sect4_View" bundle:nil];    

        break;

    default:
        break;

    }

}

This doesn't seem to retrieve the new nib, any suggestions on how to accomplish this?

Thanks.

1 Answers1

0

NSView doesn't understand the message initWithNibName:bundle:, it's NSViewController that you want. You can put a view and attached controller inside each nib, and then load the controllers with this message, if that's what you're trying to do.

I'd think the compiler would give you warnings about sending a message that may not be handled, and that the syslogs would also have warnings at runtime. Am I wrong?

abarnert
  • 354,177
  • 51
  • 601
  • 671