Re: IB 3.0
Re: IB 3.0
- Subject: Re: IB 3.0
- From: Jonathan Hess <email@hidden>
- Date: Tue, 13 Nov 2007 20:20:32 -0800
On Nov 10, 2007, at 2:33 PM, Scott F Bayes wrote:
(This was erroneously posted to cocoa-dev yesterday. I'm not an
habitual cross-poster)
Hi all,
I've been going in circles for 2-3 hours now, trying to follow an
old screensaver example from MacTech with Leopard's Xcode and IB
instead of 2.x. I can get the screensaver portion working with no
problem, but trying to build the config sheet in IB 3 has me in a
lather. It's pretty clear to me how to accomplish the tasks in 2.x
flavours of IB, but 3 has me at a standstill.
My screensaver class SoSView, comes straight off ScreenSaverView,
started by creating a ScreenSaver project in Xcode 3. Because of
this, there is not a pre-existing nib in the project.
I'm having a number of problems with the nib and IB:
- whether I add a new nib (or xib) to the project from Xcode, or
start a new nib from IB and tell it to read the .h file, I can't
seem to get IB to recognize SOSView. When starting from Xcode with
File > New file, the green light comes on in the nib window in IB,
SoS.xcodeproj is displayed next to the light, and clicking on it
jumps me to the project in Xcode, but when I want to set any of my
views' or windows' classes to SoSView, I can't see SoSView in the
list, though many familiar NS classes do show up. File > Synchronize
with Xcode from IB doesn't change the situation. My understanding
from reading this list recently is that I need to dragon drop a
control/view/window, then change its custom Class with the "i" tab
of the inspector; is that correct?
Yes. You should select your view, and then use the identity inspector
to change the custom class of the view to 'SOSView'. If the green
light is showing up in your document window and you have a .h file in
your project that defines SOSView, then this should work. What's the
base class of SOSView? Is there a header for that class? Just to be
clear, you don't need to drag and drop any header files that are in
your project, and you shouldn't have to manually use the "Synchronize
with Xcode" menu item.
- if I start my nib from Xcode, with File > New File > Interface
Builder > Cocoa > nib > Application nib or Empty nib, the new nib
joins the nib files group, and all seems hunky-dory, except for the
above Custom Class problem. The green light comes on in IB. But if I
start with New in IB and choose an Empty or Window template, I can't
for the life of me seem to associate it with the Xcode project after
that. File > Read Class Files... doesn't cause the green light to
shine, though it processes the .h without comment or error. Nib Info
panel shows N/A for Project name and Project folder; Save to the
project dir doesn't change the situation. What's the magic?
IB associates a document with a project as soon as the document's file
is referenced by a project. If you just created a nib in IB, save the
NIB to disk, and then use Xcode to add a file reference to the file
you just created. At that point, the green light will come on. This is
all more seamless if you start by creating a new nib in Xcode.
- the old instructions say to set the class of File's Owner to your
SSView sub-class, then CTL-drag from File's Owner to the window to
connect the IBOutlet designated for the window. No Joy, no outlet
available (of course, since File's Owner's class is still
NSObject!). I've never had to deal with File's Owner before (well
once, for a delegate). I assume that if I can ever get my custom
class set for File's Owner, I'll be able to see the outlet from
SoSView and connect it there, just as in 2.x. Does that sound right?
You should be able to set the custom class of File's Owner with the
identity inspector just like you do for other objects. Control+drag to
connect will only work if IB knows about your header files. Once IB
finds your headers, this should work as described.
Anyway, this is a much steeper learning curve than I'd expected for
IB, given that I've been working on another project with 2 windows,
lots of panels, and dozens of controls for 6 mo. Seems like Apple
might have wanted to create a doc "For experienced 2.x Xcode/IB
users - how to accomplish the same things in Leopard". From the list
traffic, I see that I'm not the only one struggling. The
documentation for IB seems rather obtuse when viewed from the
"experienced developer" POV: I had to skim through tons of "this is
why nibs are used" and such like, hoping I wasn't missing useful
stuff. The useful stuff (i.e. new stuff or new way of doing
something, useful for existing developers) seems to have a density
of about 20% in those initial chapters, which is why I think a
condensed version for folks generally familiar with Xcode/IB
development platforms and some of the theory behind them would be
justifiable.
I agree, this would have been a great document to have.
I think once I get past this rough patch, Im going to really like
The Leopard's Way, coz all the pieces seem to be there, ready to
work together. The brain just has to reconfigure a bit.
My guess would be that your base class to SOSView is described in a
header that isn't in your Xcode project. IB won't know about that
header and then it won't know that SOSView is a distant subclass of
NSView. That will cause SOSView to not appear in the combo box. If
worse comes to worst, you can always just type in the class name
directly into the combo box. Just because the class name isn't in the
combo list doesn't mean you can't pick it. If IB still doesn't find
your action and outlet definitions you can enter them manually into
the two table views immediately below the combo box where you declare
the custom class.
Good Luck -
Jon Hess
Hasta MaƱana,
ScottB _______________________________________________
_______________________________________________
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
References: | |
| >IB 3.0 (From: Scott F Bayes <email@hidden>) |