• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Open a window created in another nib
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Open a window created in another nib


  • Subject: Re: Open a window created in another nib
  • From: Andrea Salomoni <email@hidden>
  • Date: Wed, 28 Dec 2005 11:02:57 +0100

Thank you,

I created MYWindowController class as a subclass of NSWindowController yet, the problem is that if I write
NSLog (@"window name:%@", [self window]);
returns nil...

Maybe the problem is that I make two different istances of this class... on with IB and the other one inside my mainController app...
But the problem is : how can I connect my mainController to MYWindowController?

Thank you again

ps: already read the doc... but I'm still confused :(

Il giorno 28/dic/05, alle ore 10:50, mmalcolm crawford ha scritto:


On Dec 28, 2005, at 1:13 AM, Andrea Salomoni wrote:

I created the nib using IB and choosing new application.
After it I made a new class and instatiated it in IB, connected an outlet to the window.
I have another nib file (the main) with a button connected, I would like to open the secondary nib file window clicking on it.

If I understand correctly what you've done, this is wrong. You don't instantiate an instance of the window controller in a nib, it should be the File's Owner -- you set the class of the File's Owner to be your NSWindowController subclass. See <http:// developer.apple.com/documentation/Cocoa/Conceptual/Documents/ Concepts/WinControllersAndNibs.html>.

I added in the controller.h this:

MYWindowController * theSecondWin;
in the .m file:
-(id)init
....
theSecondWin = [[MYWindowController]alloc]init];
....
}

You should initialise theSecondWin with initWithWindowNibName: -- see <http://developer.apple.com/documentation/Cocoa/Reference/ ApplicationKit/ObjC_classic/Classes/NSWindowController.html#// apple_ref/occ/instm/NSWindowController/initWithWindowNibName:>

You typically display the window with showWindow: (see <http:// developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/ ObjC_classic/Classes/NSWindowController.html#//apple_ref/occ/instm/ NSWindowController/showWindow:>).

You should also consider giving variables more complete and accurate names.


Finally, to return to the init method, you appear to have created an infinite loop:

MYWindowController * theSecondWin;
in the .m file:
-(id)init
....
theSecondWin = [[MYWindowController]alloc]init];
....
}

When you create a new instance of MYWindowController, it will create a new instance, which will in turn create another new instance etc.

I would recommend reading <http://developer.apple.com/documentation/ Cocoa/Conceptual/AppArchitecture/index.html> and <http:// developer.apple.com/documentation/Cocoa/Conceptual/Documents/ index.html>.

mmalc

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40metagraphics.it

This email sent to email@hidden

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden
  • Follow-Ups:
    • Re: Open a window created in another nib
      • From: mmalcolm crawford <email@hidden>
    • Re: Open a window created in another nib
      • From: email@hidden
References: 
 >Open a window created in another nib (From: Andrea Salomoni <email@hidden>)
 >Re: Open a window created in another nib (From: mmalcolm crawford <email@hidden>)

  • Prev by Date: Re: Open a window created in another nib
  • Next by Date: Re: Open a window created in another nib
  • Previous by thread: Re: Open a window created in another nib
  • Next by thread: Re: Open a window created in another nib
  • Index(es):
    • Date
    • Thread