On 31/08/2011, at 3:30 PM, Guy Halford-Thompson wrote:

> This is somewhat of a basic question, but I am having a lot of trouble
> getting it to work.
> 
> When my app loads, I check for certain parameters, and then display an 
> NSWindow.
> 
> I have created the window in IB and also created a custom class
> (MyWindow).  in IB I have given the window class MyWindow.
> 
> I have added a couple of extra functions to MyWindow and now I wish to
> trigger the window to be displayed given certain conditions.
> 
> How can I display the window?
> 
> I have tried
> 
> MyWindow *win = [[MyWindow alloc] init];
> [win makeKeyAndOrderFront:nil];
> 
> but it just displays a blank window...
> 
> I am pretty sure that I have not linked the window from IB properly
> but I am really confused about how to do it and the apple
> documentation / google don't seem to be able to help.
> 
> Thanks for any help
> 

Guy, the instance of MyWindow in the nib file is the one you want to show.  So, 
you don't want to make another window in code as you have above.  The 
[[Classname alloc] init...] construct is one way to create instances of a class 
in code.  But you already have an instance in the nib file.  All you need to do 
is make a connection to your instance of MyWindow in IB.  First declare an 
IBOutlet in your nib's File's Owner class, then in IB, control-drag from the 
instance to File's Owner.  This gives you a reference to that instance in your 
code.

HTH,

Ron

PS You can also, in IB, simply check the box in the MyWindow instance's 
inspector panel to make it visible at launch.

_______________________________________________

Cocoa-dev mailing list ([email protected])

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