In article <BB704C2B966890F84220.127.116.11>,
[email]slavinshearsay.demon.co.uk[/email]localhost (Simon Slavin) wrote:
A nib cannot be self-contained, it would be useless if it were. So> I'm just learning Cocoa. I seem to be gradually getting
> my head around it but it's not easy. So I'm using
> [NSBundle loadNibNamed:"CatList" owner:"foo"];
> in an application which has more than one NIB. What, you
> are asking, is '"foo"' ? Well I'd love to tell you but
> I don't know. I completely failed to figure out what I
> should be using for the owner. Then I tried 'nil' which
> gave an error. So I tried the first non-nil thing that
> came into my head and it appears to work, silly though it
> But what should I really be using for owner ?
you'll notice in Interface Builder, every nib has an object called
File's Owner. That object is not actually part of the nib, it's an
external object that "owns" the nib and its contents. As you may have
guessed, the object you pass to loadNibNamed:owner: becomes the File's
Owner object for the nib file.
So, what do you pass to it? It depends on what you want to do. Normally
you pass self, since typically you're loading the nib for yourself and
not for someone else.
You may also want to make your object a subclass of NSWindowController.
Most of the time when you load a nib it's to get a window on the screen,
which is what NSWindowController is made for. It hides the nib loading
(a little bit) and does a bit of work for you.