Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

larswik

macrumors 68000
Original poster
Sep 8, 2006
1,552
11
I finished a project a couple weeks ago that had 4 windows all with in the same .xib file that I use the 'makeKeyAndOrderFront'. This worked fine until they click on the red dot to close the window. When they tried to open it again it crashed the program. I ended up removing the red dot in IB.

The new project I'm working on I made separate .xib files for the different windows. This was a good tutorial on how to do it http://www.youtube.com/watch?v=Z1Erw7aP0EQ by the way. But I am having a heck of a time to get settings I enter into the second window to show up in the first window.

So I was wondering, is there a rule of thumb when to use a second window in the same xib and MKAOrderFront or create a second .xib file and instantiate a new Window object?
 

gnasher729

Suspended
Nov 25, 2005
17,980
5,565
I finished a project a couple weeks ago that had 4 windows all with in the same .xib file that I use the 'makeKeyAndOrderFront'. This worked fine until they click on the red dot to close the window. When they tried to open it again it crashed the program. I ended up removing the red dot in IB.

The new project I'm working on I made separate .xib files for the different windows. This was a good tutorial on how to do it http://www.youtube.com/watch?v=Z1Erw7aP0EQ by the way. But I am having a heck of a time to get settings I enter into the second window to show up in the first window.

So I was wondering, is there a rule of thumb when to use a second window in the same xib and MKAOrderFront or create a second .xib file and instantiate a new Window object?

Most likely the window that crashed was marked as "delete when close". So when the user closed it, the window got removed, you got a garbage pointer, and then you tried to send "makeKeyAndOrderFront" to the garbage pointer.
 

larswik

macrumors 68000
Original poster
Sep 8, 2006
1,552
11
That is what I kind of thought happened. So in my new project as I am still learning I am trying to find out when to create a second window in the same MainMenu.xib, or when to create a new .xib file to a new window?

Are their any guide lines?
 

mfram

Contributor
Jan 23, 2010
1,304
341
San Diego, CA USA
I would almost surely use the method described in this video for any sub-window which is more than just trivial. Maybe for something like a simple status window you don't need this method.

But if there's any separate logic in this second window, it would probably be best to separate out the secondary window's controller from the main window's controller. The point of object-oriented design is to encapsulate logic as much as possible. The method shown in the video meets that goal. Looks very straight-forward to me.
 

larswik

macrumors 68000
Original poster
Sep 8, 2006
1,552
11
Thanks for that explanation. I am getting a little lost with second windows and I am more or less approaching it wrong. I was trying to unclutter the 1st window so I created a second window with a button and a test fields. I enter the information and press the NSbutton which should have added the string in the NSTextField to an NSPopUpButton in the first window.

But it worked fine if I created a second window within the first xib. That is when I wondered when you use one of the other.

Thanks

-Lars
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.