Re: Connections
Re: Connections
- Subject: Re: Connections
- From: Chris Gehlker <email@hidden>
- Date: Wed, 08 Aug 2001 11:16:30 -0700
On 8/8/01 9:22 AM, "email@hidden" <email@hidden> wrote:
>
I've been trying to get my head straight about connections, to no
>
avail. I think I understand the connections between view and controller
>
in a .nib: this is more of a "wiring diagram" for making actual
>
connections with the real objects when the .nib is loaded.
>
>
What confuses me is the connections between controller and model. For
>
example, on page 117 of "Learning Cocoa" the author(s) state: "Because
>
instances of this model class don't communicate directly with the
>
interface, there is no need for outlets or actions." But then 2 pages
>
later it states "Make an outlet connection between ConverterController
>
and Converter"--which is the model object referred to 2 pages earlier.
>
If this connection is necessary, then why isn't another connection from
>
the model back to the controller needed in order to return the asked for
>
value?
First, It is confusingly written. Let me see if I can help. On page 117 the
book is talking about the Converter class. It doesn't need any outlets
because it doesn't send any messages. It on RESPONDS to messages from
CoverterController.
On page 119 you are dragging FROM ConverterController TO Converter so it is
ConverterController that's getting the outlet.
>
I have seen no discussion concerning making connections between model
>
objects; is it just assumed that I'm supposed to know that I have to
>
ctrl-drag in Interface Builder before a message can be sent? Or can the
>
message be sent without this explicit connection? And what about
>
notifications? Is there a radio metaphor here as well as a wiring
>
metaphor?
Here is the big picture that this example is supposed to convey:
Model objects tend to send messages only to self and super. They don't need
outlets or targets. They just sit there and crunch or wait for messages from
the outside. These messages come from controller objects and sometimes from
scripts.
View objects sit between the user and the controller. You draw lines from
the view to targets in the controller and from the controller to view
objects because the communication is two-way.
Controller objects sit between the view and the model. Communication can be
initiated by either the view or the controller so controllers need both
outlets to the view and targets from the view. But communication between the
controller and the model is always initiated by the controller so
controllers need outlets TO the view but they don't need targets from the
view.
Try thinking of the model as the suspect who never volunteers anything and
the controller as the detective who is interrogating her.
Hope that helps.
--
Tact is the ability to describe others as they see themselves. -Abraham
Lincoln, 16th president of the U.S (1809-1865)