File's Owner
File's Owner
- Subject: File's Owner
- From: Johnny Lundy <email@hidden>
- Date: Fri, 23 May 2008 14:49:16 -0400
I decided to once again go verbatim through Cocoa Fundamentals. So far
it has been largely "uh-huh, yep", but the File's Owner, my nemesis,
comes up again.
http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaFundamentals/CommunicatingWithObjects/chapter_6_section_3.html
You connect an outlet in Interface Builder, but the procedure starts
in Xcode. The following steps describe the procedure:
When defining your custom class, declare an outlet by tagging the
instance variable with the IBAction qualifier.
In Interface Builder, drag a generic object into the top level of
the nib file window (if one doesn’t already exist for your custom
class).
If an instance of your custom class is to be the File’s Owner for
the nib file, this step is not necessary. Also, if you’re defining a
custom NSView object, select that object instead.
Import the custom class into Interface Builder.
With the generic object (or File’s Owner) selected, type the name of
your custom class in the Class field of the Identify pane of the
Interface Builder inspector. This assigns your custom class as the
class of the selected object. This step has to be done only once.
Select your custom instance (or File’s Owner).
Right-click or Control-click this object to display the connections
panel.
Find your outlet under Outlets and drag a connection line from the
circle next to the outlet to the object on the user interface that
you want that outlet to reference.
I sent feedback on this as File's Owner is mentioned several times and
not defined. There seems to be some huge problem with File's Owner.
Even Aaron Hillegass says that people have trouble understanding
File's Owner - and sure enough, when I read his explanation, I
remained clueless.
I can follow making a generic NSObject set to my custom class, but why
File's Owner?
My birthday is coming up and if I can understand File's Owner, I will
consider that one of the best presents.
As usual, I can recite the documentation without understanding it :
File's Owner is a proxy object that is set at nib load time to the
object that loaded the nib (I don't know what object loaded my nib, so
that does not help me). In MainMenu.nib, this is the application
instance, which is a shared singleton instance of NSApplication (how
all applications can share this is beyond me), which is also set to
the global variable NSApp (uhh, OK...).
That's all well and good, but what exactly is this thing? Why would I
succeed in having an outlet in my class if I set the Class Identity of
File's Owner to my custom class? Why should I set File's Owner's Class
Identity rather than the Class Identity of a plain NSObject that I
drag out of the Library in IB?
_______________________________________________
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