Re: same table, different delegates
Re: same table, different delegates
- Subject: Re: same table, different delegates
- From: Jonathan Jackel <email@hidden>
- Date: Thu, 25 Dec 2003 15:36:34 -0500
Koen,
The Model-View-Controller (MVC) design for writing applications is
quite popular because of the exact problem that you face. All the
pieces (e.g., the table view and data that gets shown in the view) are
separate. They can then be reassembled into a variety of combinations.
You sound unfamiliar with the MVC idea. You should read about it here:
http://developer.apple.com/documentation/Cocoa/Conceptual/
AppArchitecture/Concepts/MVC.html
I have a window with a table to display some data. The window is the
delegate so I set up all the code for populating, sorting the table in
the window code.
Do you mean delegate or datasource? Or both? It is relatively common
to have a separate object, called a controller, handle this chore.
Typically you would not make a user interface element (a window or a
view) the delegate or datasource of a tableview.
Now I am adding a feature to the app that uses different window, but
the same table, using different data.
Do you mean it uses the same class of table? Or the same instance?
So the populating, sorting code is all the same. I can of course just
copy all the delegate code from one window to the other, but it seems
to me that I can do this easier, maybe by creating a MyTableView
class.
No, the simplest thing is to have one object that can control all your
tables, no matter what window they are in. A controller.
In that case, I guess I need to put all the code in the table class,
not in each window. Is this a good approach, in other words, can I use
a table by itself, without the delegate?
It would probably help you a lot to check out the "Currency Converter"
example
_______________________________________________
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.