If you created a window in IB and it is in your main nib file, you cannot create a โnew instanceโ every time you click a button. When you create an object in the nib file, the instance is actually created by IB, and then archived into the nib file, so you get this instance. Assuming your window is connected to a variable named auxWindow on the same object that responds to your click on the button, and the action message is called buttonClick , you can do something like this to show it:
-(IBAction)buttonClick:(id)sender { if(! [auxWindow isVisible] ) [auxWindow makeKeyAndOrderFront:sender]; }
This will cause the aux window that you defined in IB to appear on the screen and become the key window (and the main window in the application). Please note, however, that if you intend to reuse this window, you must uncheck the IB Inspector that says Release on Close, otherwise you will receive an access violation the next time you click the button.
This is a simple answer to your basic question, but window programming can be quite complicated and usually very specific (for example, do you really need a panel for what you are doing?) ... so I highly recommend that you read the Guide to programming windows for more information on this topic, and then ask very specific questions here when you are stuck.
source share