How does one build a simple nib file to control a window?

  • I am stumped by what ought to be a very simple task:

    I tried to build a Window nib file; the window to be controlled
    by an NSWindowController subclass called myController.
    Ought to be a snap.  But the window wouldn't display correctly
    so I overrode this method in the controller:

      - (void) windowDidLoad {      //      for debugging
      NSLog(@"myController: loaded window.");
      NSWindow *w = [self window];
      if (w==nil) NSLog(@"myController: but  self window is nil !");
    }

    And although the nib file loaded, the window did not!  It was nil!

    So I went looking for examples to copy and found "SKTInspectorController"
    in Developer/Examples/AppKit/Sketch.  I reduced code and nib files
    drastically, so that mine and theirs were "nearly" the same, and ran
    both in a little driver program. Theirs works, mine doesn't.

    Looking at the 'Classes" views, both of us have sub classed
    NSWindowController, and named the subclass.

    After more sleuthing, I find a difference I cannot eliminate,
    nor can I build a file like theirs:

    The 'Sketch' nib file has three objects in the Instances(icon) view:
    "File's Owner", "First Responder", and "Panel".
    My nib file has those, and a fourth: "myController".

    But, looking at the Instances(outline) view, I see that they have
    managed to get 'NSObject' renamed as their subclass; whereas
    in my nib file, 'NSObject' still appears, and my subclass is the
    4th (extra?) object.

    This extra(?) object appears when I "instantiate" my subclass.

    My connections between the controller subclass and the window
    are the same as in Sketch.

    Try as I may, I can't find a sequence of actions in the Interface Builder
    to create a nib file with only three top-level objects, with an
    NSWindowController as the  file owner. I've read the Interface Builder
    manual and help, and searched the 'net.

    What do I fail to understand?
  • On Oct 12, 2007, at 6:14 PM, James Stein wrote:

    > What do I fail to understand?

    You need to:

    1. Set the file's owner to your NSWindowController subclass, which
    you can do by setting the file's owner's custom object setting (using
    the info panel) to the name of your NSWindowController subclass.
    2. Delete the NSWindowController subclass you instantiated.
    3. Connect the window to the NSWindowController subclass' "window"
    outlet.

    Nick Zitzmann
    <http://www.chronosnet.com/>
  • Am 13.10.2007 um 02:20 schrieb Nick Zitzmann:
    > 1. Set the file's owner to your NSWindowController subclass, which
    > you can do by setting the file's owner's custom object setting
    > (using the info panel) to the name of your NSWindowController
    > subclass.

      Nick meant to write "Custom Class", not custom object. It's a
    section in the inspector.

    Cheers,
    -- M. Uli Kusterer
    http://www.zathras.de
  • > 1. Set the file's owner to your NSWindowController subclass, which
    > you can do by setting the file's owner's custom object setting (using
    > the info panel) to the name of your NSWindowController subclass.
    > 2. Delete the NSWindowController subclass you instantiated.
    > 3. Connect the window to the NSWindowController subclass' "window"
    > outlet.

    4. Make sure the file's owner is connected to the window's "delegate"
    outlet.

    --
    Scott Ribe
    <scott_ribe...>
    http://www.killerbytes.com/
    (303) 722-0567 voice
previous month october 2007 next month
MTWTFSS
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31        
Go to today