I am new to Cocoa and I don't understand the concept of File's Owner
of a .nib file.
Here is the way I would see things :
Consider a file
myNibFile.nib
file that describes how a window looks.Now, I want to connect an actual window to this .nib file. So, I create a class
myWindow
, which is a subclass ofNSWindowController
. And, to do this connection, I change theinit
method like this:-(id)init { [super initWithWindowNibName:@"myNibFile"]; return self; }
So, I understand that when I create an instance of myWindow
, the "system" will go and look at the .nib file and create the adequate object.
So, my question are :
why do I have to specify that the
File's Owner
of my .nib file ismyWindow
? Isn't it redundant ?I guess it means I didn't really understood what the
File's Owner
. What is it ? Why does the .nib file have to belong to something ? Can't it be "somewhere" in my "application" and when it is needed, the "system" goes there and use it ?
Thanks for helping me to see more clearly in these new concepts !
See Question&Answers more detail:os