Re: Interface Builder question
Re: Interface Builder question
- Subject: Re: Interface Builder question
- From: Chris Hanson <email@hidden>
- Date: Mon, 29 Jul 2002 23:59:06 -0500
At 9:03 PM -0600 7/29/02, Terry Simons wrote:
The fact that when you click on button "X" which is defined in your
NIB file, it calls function "abc" in your code.
You mean "it sends abc: to its target."
In Java, for instance, you actually have to say... "I want a button
named 'Button' and I want it put here in such and such panel, and I
want it to call such and such method."
And this is one of the biggest problems with Java. Other systems
were using some form of interface specification files or resources to
create human interfaces in the early 1980s. That Sun didn't include
it from the first release of Java 1.0 in 1994 is a huge oversight.
In IB, I'm defining my buttons, and making a connection that tells
the button to call function xyz, but I'm not seeing any of the code
for the GUI.
Right. There isn't any code generated that creates your human
interface. (Note: Macintosh developers say "human interface" or
"interface" rather than "GUI." Just a cultural thing.)
This is very cool, in that I don't have to worry about it, but at
the same time, I'm a little bit confused about how the various
pieces interact...
Essentially, IB writes a description of all the objects in your
interface to the nib file, along with a description of the
connections between them. Then, when you ask NSBundle to load a nib,
the nib-loading mechanism looks through this description, and creates
all of the objects described. It also uses the Objective-C runtime
to set the instance variables in the objects it creates according to
what you specified in the IB inspector for each object.
Then it looks at all of the connections, and uses the Objective-C
runtime to set the appropriate instance variables in the objects it
creates. (As well as any appropriate instance variables in the
"owner" object passed to +[NSBundle loadNibNamed:owner:].)
It's becoming more clear as I play with things though.
I guess what I really meant to say was...
Is IB required to build an application with Cocoa?
No. You can build applications by hand. There's an example in the
Garfinkel & Mahoney book. But you'll wind up doing a whole lot more
work for a whole lot less benefit, and less long-term maintainability
& flexibility.
Do I *have* to set my windows up in IB? Can I programmatically
define a window, and manually add buttons to it?
You can, but you probably don't want to. It's far, far easier to use
IB. Especially once you figure out how to take advantage of the IB
architecture things really modular.
-- Chris
--
Chris Hanson | Email: email@hidden
bDistributed.com, Inc. | Phone: +1-847-372-3955
Making Business Distributed | Fax: +1-847-589-3738
http://bdistributed.com/ | Personal Email: email@hidden
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.