Re: IB does not show Outlet/Action section in inspector
Re: IB does not show Outlet/Action section in inspector
- Subject: Re: IB does not show Outlet/Action section in inspector
- From: Kevin Cathey <email@hidden>
- Date: Wed, 23 Sep 2009 11:12:53 -0500
1. In any of your project's nib files, go to the Library window (not
the Inspector window) and select the Classes tab. Using the pop-up
menu at the top, select one of your project's classes in the very
long and awkward hierarchical menu. For example, your class
MyDocument would appear in the menu under NSDocument if it inherits
from NSDocument.
You don't have to use the pop-up at all (Bill, based upon your
description here, are you seeing the flat list of classes in the
middle of the classes tab?). There are three fast ways to use the
Classes tab:
The fastest way is to use the search field at the bottom of the
Library window. If you use Command-Option-F, then the library appears
and the search field takes focus. I typically always have the Classes
tab up since I can not only instantiate any class with it into my
document, but I can also see the lineage for the class, see where it
is defined, and of course add actions and outlets.
If you are working in the design canvas and want to add an action or
outlet to a class, select the instance of the class you want to add
the outlet or action to and then use Command-Option-Right-Arrow to
quickly reveal that class in the classes tab.
In the list of classes in the Classes tab, you can use type selection
to quickly jump to a class. For example, "NSApp" jumps to NSApplication.
Now as for the motivation for putting the outlets and actions into the
Classes tab, here is a response I just put on xcode-users:
I wonder why the outlet/action UI was moved there … This is all the
more confusing because you *can* add outlets to First Responder in
the Identity inspector.
The actions and outlets were moved to the Library for the following
reason: actions and outlets live on classes, not instances of classes.
The Classes tab represents all of the classes you can use in your
Interface Builder document, these come from your Xcode project, from
frameworks you've linked against, from manually added headers, from
plugins, and from the document itself (by setting the custom class on
an object, setting the type of an outlet/action, or using the new
Subclass menu item in the Classes tab). With this universal list of
classes, it makes sense to edit the class itself.
Now First Responder is an interesting item. First Responder is itself
not a class, so it does not make sense to put it in the Classes tab.
In Cocoa, First Responder really acts like an instance. The actions
for First Responder are attributes for it, and that is why they live
in the Attributes inspector for First Responder.
I hope that clears some of that up…
Kevin
On 23 Sep 2009, at 08:26, Bill Cheeseman wrote:
On Sep 23, 2009, at 7:11 AM, Gregory Weston wrote:
There is no mechanism in the current version of the tools for
defining outlets and actions in IB; only for assigning them.
I don't believe this statement is true, if I understand your point
correctly. Here's how to create an outlet or an action in IB 3.2 and
write it back to your source files. You can also create wholly new
classes this way.
1. In any of your project's nib files, go to the Library window (not
the Inspector window) and select the Classes tab. Using the pop-up
menu at the top, select one of your project's classes in the very
long and awkward hierarchical menu. For example, your class
MyDocument would appear in the menu under NSDocument if it inherits
from NSDocument.
2. In the bottom pane, select the Outlets or Actions tab.
3. Near the bottom of the window, click the Add (+) button. Type a
name for the new outlet or action and a return type (which should be
void for actions).
4. At the bottom of the window, use the Action button and choose
Write Updated Class Files.
5. In the dialog that comes up, choose to save the file to the
original name for the implementation file.
6. In the warning alert that comes up to tell you that file already
exists, choose Replace to incorporate your new outlet or action in
the existing file, or Merge to bring up FileMerge and give yourself
a chance to accept or reject individual changes.
7. Lock at your header file. The new outlet or action is right
there. (The setter and getter methods or properties for outlets are
not produced by this technique, however.) Look at your
implementation file. If you created an action, a stub method
definition appears.
Is this less than what you used to be able to do in IB? To the best
of my memory, it gives you more control over what is produced.
--
Bill Cheeseman
email@hidden
_______________________________________________
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