Re: File's Owner
Re: File's Owner
- Subject: Re: File's Owner
- From: Uli Kusterer <email@hidden>
- Date: Mon, 26 May 2008 10:17:13 +0200
Am 24.05.2008 um 04:58 schrieb Andy Lee:
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.
Err... I'm not sure if we're confusing the OP here by piling on more
and more information not immediately relevant, but here goes a little
clarification for the above point: The reason the above works is that
NSApp is a singleton. So, what somebody is probably doing is taking
advantage of its global scope and just accessing it directly. The
File's Owner is here, because NIBs can be used in many other cases
(which I mentioned before), and in most of those cases the owner is
not a singleton. Quite the opposite, in fact:
When you open a new file in an NSDocument-based app, NSApp creates a
new NSDocument(-subclass) object for each file, and each loads its own
copy of the NIB. That way, you can have several windows in the app,
all built using the same code, all created from the same blueprint in
a NIB, but all showing different data (from different files).
Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de
_______________________________________________
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