Modal Windows and XIB files

Discussion in 'Mac Programming' started by BadWolf13, Sep 8, 2010.

  1. BadWolf13 macrumors 6502

    Dec 17, 2009
    I'm reading up on Modal windows, and based on the documentation, it seems like the only way to use runModalForWindow: is if the window I want to run as a modal is included in the XIB file for the main application. Am I correct in this, or can I store that window in a separate XIB file and call it with that method?
  2. kainjow Moderator emeritus


    Jun 15, 2000
    You can store the window anywhere. Generally though, you should have one window per nib, so you're not loading resources unnecessarily. NSWindowController makes this easy.
  3. BadWolf13 thread starter macrumors 6502

    Dec 17, 2009
    That's what I was thinking, since this "modal" window won't be used in every instance, I don't want to use unnecessary resources. If said window was in a separate XIB file but had a window controller called myWindowController, could I use a code like;

    runModalForWindow:[myWindowController window]
    Would that work?

Share This Page