Re: Bypassing Interface Builder
Re: Bypassing Interface Builder
- Subject: Re: Bypassing Interface Builder
- From: "I. Savant" <email@hidden>
- Date: Wed, 14 May 2008 20:43:19 -0400
Graham, your responses were very well-put. I had to step away from
this thread to meet some deadlines today and I'm glad to see where
it's gone for the most part. I rushed to the defense of IB because,
for what it is intended, it really is a powerful and useful tool.
Unnecessary struggle is silly, more so on a device designed to
eliminate just that.
Now to my point:
You probably didn't mean what you wrote, but if you did, then you
would have had trouble - IB doesn't *ever* want you to do this. You
drag FROM outlet TO control. You drag FROM control TO target +
action method. It's always FROM source TO destination.
I'd like to expand on this a bit. It's important to think of
"messaging objects" here. In Objective-C we are supposed to refer to a
method call as a "message".
[someObject performSomeAction];
In this sense, we can easily visualize a "flow" of messages from a
sender to a receiver. In Interface Builder, this concept is key to
understanding the "connections" you establish by ctl-dragging from one
object to another.
The two types of connections Interface Builder allows serve two
different purposes to achieve and/or facilitate this flow. An IBOutlet
gives you the ability to name an object instance so you can send it
messages by name. An IBAction allows you "codelessly" specify both the
target and action of a control.
In the case of IBOutlet, an example of this is creating a
"nextButton" outlet in an AssistantWindowController object and
connecting an instance of it to a "Next" button in an assistant window
so that you can enable or disable the button (or change its title to
"Finish") when certain things happen (of course you can use Bindings
for this). In this case, the owner of the outlet wants to be the sender.
In the case of an IBAction, an example is the -nextPage: method of
an "AssistantWindowController". Connecting the button's action to the
AssistantWindowController's -nextPage: method means that when the
button's action is fired, that AssistantWindowCotroller instance
receives the -nextPage: action with the next button as its sender. In
this case the owner of the action wants to be the receiver.
Interface Builder is just a GUI tool (in two senses) that lets you
instantiate views and controllers and wire them up with names and
actions mostly through drag-and-drop. Doing so entirely in code is
ridiculously tedious by comparison.
--
I.S.
_______________________________________________
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