Re: Newbie question
Re: Newbie question
- Subject: Re: Newbie question
- From: Matt Neuburg <email@hidden>
- Date: Wed, 11 Feb 2009 11:49:43 -0800
- Thread-topic: Newbie question
On Wed, 11 Feb 2009 13:45:08 +0100, TrePos <email@hidden>
said:
>Hi,
>
>Sorry to bother with a newbie question but I'm kinda stuck. I fail to
>grasp the concept of interface builder. I know it sort of generates
>object meta information which is instantiated at program startup and
>thus eases the UI design process. I just have difficulty understanding
>how the 'connection' between IB defined objects and 'coded' objects
>work.
The docs are actually pretty good:
<http://developer.apple.com/documentation/DeveloperTools/Conceptual/IB_UserG
uide/Introduction/chapter_1_section_1.html>
And especially (for the question you are asking):
<http://developer.apple.com/documentation/Cocoa/Conceptual/LoadingResources/
CocoaNibs/chapter_3_section_1.html>
To sum up: Every "thing" in your running code is an object, which is an
instance of a class. There are no "things" unless some class is
instantiated. Every "thing" in Cocoa can be instantiated entirely in code.
For example, you could write code to make a new window (NSWindow instance)
and put a button in it (NSButton), doing the usual alloc-init dance. You
don't *need* Interface Builder at all.
So now let's talk about Interface Builder. There are two kinds of object
shown in the main IB window: real object and proxy objects.
A proxy object is just a proxy; it is a mere stand-in for an object that
will be instantiated in your code. Examples: File's Owner, First Responder,
Application.
A real object - for example, a window - will be instantiated "in the nib".
This means that it is actually a set of instructions for instantiating the
object. A window that you design in Interface Builder will effectively be
translated, when the nib loads, into the very same code that you would use
in Objective-C to create the window and populate it with whatever controls
it contains.
Okay, that's not quite true. Actually, archiving is used.
<http://developer.apple.com/documentation/Cocoa/Conceptual/Archiving/Archivi
ng.html>
A nib file is effectively an archive, and when the nib is loaded, its real
objects are unarchived. This instantiates them. Now they can be sent
messages in code, and the first such message that they can be sent is
awakeFromNib:
<http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Pro
tocols/NSNibAwaking_Protocol/Reference/Reference.html>
m.
--
matt neuburg, phd = email@hidden, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/matt/default.html#applescriptthings
_______________________________________________
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