Newbie Question - Multiple Windows

Discussion in 'Mac Programming' started by wgshiver, Jul 6, 2011.

  1. wgshiver macrumors newbie

    Jul 6, 2011
    Alright I am new to Apple development and Objective C. I understand the Objective C code pretty good. The part I am struggling with is how to display one window before showing the main window. What I need to do is display a small window with 3 text fields that grabs information. After that information is obtained it passes off control to the main window which will display the a WebView. I have created to xib files but that is as far as I have gotten

    I cannot seem to figure out how to show one window and then close it and pass control to another window. Can someone help me understand this or is there a tutorial somewhere I can read. It seems like this would be very simple I am just not getting it for some reason.

  2. mfram macrumors 65816

    Jan 23, 2010
    San Diego, CA USA
    First you're going to have to decide whether the standard Apple dialog classes are going to be enough to get your information. Not sure offhand. Read the "Dialog Guide" to figure out if that's enough. If not, you'll have to make a separate xib with a window and controller in it to prompt the user.

    As for how to get it into your program, I can think of some options:

    1. Keep your app as the main window, but immediately bring up a dialog box when the program starts asking for the information. Probably the most straight forward.

    2. Make the initial dialog your "main" window. Get the information you need, then close the window. After that, start your application window using a separate xib and controller.

    3. Modify the app delegate to open up a window and controller in a separate xib right before your main program starts. I guess you'd have to do this in the applicationWillFinishLaunching method.

    As for opening a new window, the general idea is to create another xib with a window and a controller object in it. Then you'd use NsNib's initWithNibNamed:bundle: to initialize a NSNib object and instantiateNibWithOwner:topLevelObjects: to launch the window.

Share This Page