Re: Question about MVC
Re: Question about MVC
- Subject: Re: Question about MVC
- From: "I. Savant" <email@hidden>
- Date: Wed, 26 Apr 2006 09:02:18 -0400
Craig:
I admit I don't fully appreciate the particulars of your problem.
Once you start mixing non-Cocoa stuff with a Cocoa application
(especially on the scale of porting existing apps), it's not always a
clear-cut case. I'm afraid I can't be much help there. :-)
If all your asking is if there's a standard way of doing it, there
are several mechanisms. The simplest one is just to create an outlet
for a simple reference.
For example, I have a view called "Report View" that draws graphs
and blocks of text according to a template and data provided by the
controller. It has an outlet called "reportController". I connect it
in IB to my report controller. The report controller has an outlet
called "reportView". Can you guess what that's connected to? ;-)
It really can be as simple as that. If my controller needs to tell
my report view anything, it has a reference to it. Likewise for the
view with the controller. They're cross connected and work just fine.
For additional fortitude, I add simple logic like "if
(reportView)..." to make sure no actions are taken if the outlet is
not connected (the view appears "blank", which clearly indicates to
me that it's not connected in this case). Not sure this is necessary
in a shipping application, but it sure helps during the development
process ...
--
I.S.
On Apr 26, 2006, at 8:48 AM, Craig Dooley wrote:
I.S.,
I am trying to port the X11 rdesktop program over to cocoa, so my
model is actually a bunch of imported C code, and my view takes care
of output to the screen, and input. I need to track mouse motion,
button presses, etc, and am trying to figure out the cleanest
separation to do that with.
I don't really want to call functions in the Model from my event
response code, so I think I need a way to forward these messages to my
controller. I did not find any good examples of how a view can send
information back to a controller anywhere, and was mostly wondering if
there is a standard way to do it in Cocoa. I am reading through the
Cocoa Fundamentals guide now to see if there is there is just
something I missed.
-Craig
On 4/26/06, Kenny Millar <email@hidden> wrote:
I.S,
That's an interesting reply, and I understand exactly your point
of view.
However I too am currently pondering an MVC design, where I can't
think of
any other way but by having the view maintain an instance variable
of the
controller... let me explain.
My data contains a set of objects, which the view renders to the
screen.
When the user clicks in the view, whichever object he clicked on
becomes the
'current' object, and the controller needs to know which is the
'current'
object. How can you do that without the view telling the
controller, and how
can the view tell the controller without either i)using a
delegate, or
ii)maintain an instance variable and sending messages to the
controller?
Maybe I just haven't grasped the full MVC picture yet, but I'm
just a newbie
so willing to be shown the right direction!
-Kenny
-----Original Message-----
From: cocoa-dev-bounces+kennymillar=email@hidden
[mailto:cocoa-dev-bounces+kennymillar=email@hidden] On
Behalf Of
I. Savant
Sent: 26 April 2006 13:24
To: Craig Dooley
Cc: email@hidden
Subject: Re: Question about MVC
Craig:
I think what you really mean (or need to mean, anyway), is that
you want to have your view tell your controller to initiate the send
(likely of data in your model layer).
<snip>
--
----------------------------------------------------------------------
-
Craig Dooley <email@hidden>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40gmail.com
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden