Re: Some MVC questions
Re: Some MVC questions
- Subject: Re: Some MVC questions
- From: Kyle Moffett <email@hidden>
- Date: Thu, 18 Jul 2002 18:17:20 -0400
The model is the actual data structures that underly everything, so use
an NSArray/NSMutableArray filled with subclasses of NSObject (MyNode).
The controller is a special subclass of NSObject (MyGraphController)
that has the NSArray/NSMutableArray as a data member, it should do most
of the processing. The views are your subclasses of NSView, MyGraphView
and MyGraphPalette or whatever. When MyGraphView needs to draw itself,
it would ask about each node, and the MyGraphController object would
lookup the data in the appropriate MyNode object. When the user selects
a node and clicks delete, the MyGraphView would tell the
MyGraphController to delete the node, and the Controller would do it.
For adding, the MyGraphView would accept a drag from the MyGraphPalette,
and tell the MyGraphController about it.
HTH,
Kyle Moffett
On Thursday, July 18, 2002, at 03:32 PM, Koen van der Drift wrote:
Hi,
I have some questions regarding the implementaion of the mvc paradigm
in my app. My app displays a datamodel (a directed acyclic graph, to be
more precisely) in a window. The user can edit the graph by dragging
nodes from a palette (in a separate window) to the main window, or by
selecting the nodes and delete them, or move them around.
So, this is what I have in mind:
Model: the graph itself - probably a subclass of NSMutableArray, and
each node is a subclass of NSObject.
View: MyGraphView, a subclass of NSView. This forwards received drags
and mouseclicks to the graph. And it draws the graph (actually it tells
the graph to draw itself in the view)
Controller: ??? - now I am stuck. What should this class take care of?
Is it an intermediate between the view and the graph, eg when an object
is added or moved?
And how does the palette fit into the MVC scheme?
Any input is appreciated.
thanks,
- Koen.
_______________________________________________
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.