Until now I have created my GUIs using IB. I want a better understanding of what goes on "under the hood" of instantiating a Nib, so decided to try adding a button to a window programmatically. I can't get the button to appear, and so presume I am missing some fundamental concept. Here's my code:

        NSButton *button = [[NSButton alloc] init];
        [button setTitle:@"New Button"];
        [button setHidden:NO];
        [button setButtonType:NSPushOnPushOffButton];
        NSPoint p = NSMakePoint(0, 0);
        [button setFrameOrigin:p];

        NSView *theWindowContentView = [theWindow contentView];
        [theWindowContentView addSubview:button];
        [theWindowContentView setNeedsDisplay:YES];
        [button release];

"theWindow" is an ivar that is set by Nib loading to hold a reference to the window (my controller object is instantiated in the Nib). Again, I know I must be overlooking something fundamental, so would appreciate some guidance on the mechanics of instantiating controls programmatically. TIA.
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to