Re: creating a new class and instance
Re: creating a new class and instance
- Subject: Re: creating a new class and instance
- From: Chris Hanson <email@hidden>
- Date: Tue, 4 Dec 2007 18:12:55 -0800
On Dec 4, 2007, at 5:29 PM, Roland Silver wrote:
In Leopard/Interface Builder, how do I create a new class and
instantiate it?
This is a FAQ that has been answered numerous times here on xcode-
users as well as on the cocoa-dev list. Searching the list archives
for Interface Builder 3 should turn up some useful results.
For completeness, here's a summary of the new class/instance
functionality in Interface Builder 3:
To create an instance of a class in Interface Builder 3, you always
drag an object out of the library.
If you want to create an instance of a custom class, drag an instance
of its closest superclass -- such as NSView or NSObject -- out of the
library, and then set its class to your custom class via the Identity
Inspector's "Class Identity" slice.
If your nib/xib file is in an open Xcode project, and you have already
created your custom class in Xcode, Interface Builder will list it in
the combo box and automatically show its outlets and actions. If you
haven't defined your custom class yet, you can type the name you want
it to have and define its outlets and actions in the Class Identity,
Class Actions, and Class outlets slice.
If you want to generate files for your custom class from Interface
Builder, select an instance of that custom class and then choose
"Write Class Files..." from the File menu. You can choose to generate
Objective-C, Ruby or Python files.
Once a nib file is part of a project and a custom class used in that
nib file is defined in that project, Interface Builder will
automatically keep the outlets and actions for that class up to date
with any changes you make within Xcode. This is one-way: Changes you
make in Interface Builder will not be reflected in Xcode. You can,
however, add an outlet or action in Interface Builder, highlight it in
the Class Outlets or Class Actions table within Interface Builder, and
then paste a declaration for it into the appropriate place in a code
file within Xcode, and the right thing will happen.
-- Chris
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden