Re: File's Owner
Re: File's Owner
- Subject: Re: File's Owner
- From: Andy Lee <email@hidden>
- Date: Fri, 23 May 2008 22:58:56 -0400
On May 23, 2008, at 9:55 PM, Erik Buck wrote:
What other objects outside the nib? I have nothing connected to
File's Owner except the delegate, and looking at
STOP. You just answered your own question. You connected the
delegate outlet of an object outside the nib to some object within
the nib. That is why File's owner exists! You just used File's
Owner to make a connection to an object outside the nib. That
object is the application's one and only NSApplication instance.
Exactly -- you answered your own question.
The application instance is created behind the scenes for you just
after your application starts launching but before the main nib is
loaded. By definition (since the nib hasn't been loaded yet) the
application instance is outside the nib. Again: the application
instance exists *before* MainMenu.nib is ever loaded. Then, when
MainMenu.nib *is* loaded, the application instance is set to be the
File's Owner for that nib.
I had a view object send an action to my class, by coding
(IBAction) myMethod: in my code, and setting that action in the
view object's action method.
As it turns out, you can do what you just described perfectly well
without using File's Owner and your application will be just fine.
The reason is that when your nib file was loaded, your window was
instantiated (remember that your window is one of the objects
described in the nib file), and when a window is instantiated it's
automatically added to the application instance's window list. So
this is actually another connection between an object outside the nib
(the application instance) and objects in the nib (your window or
windows) -- a connection that is made for you that doesn't require use
of File's Owner. None of us thought to mention this connection (that
I recall), because we were focused on the general explanation of
File's Owner.
Again, if any of this or anyone else's answer is not clear, please try
to help us help you by pinpointing *where* we start to lose you.
--Andy
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden