Re: Data Source object for NSTableView
Re: Data Source object for NSTableView
- Subject: Re: Data Source object for NSTableView
- From: Ryan Bates <email@hidden>
- Date: Sat, 21 Feb 2004 09:39:28 -0800
On Feb 19, 2004, at 10:38 PM, Jerry Krinock wrote:
I'm thinking of wiping out my Data Source object, and incorporating
all its
methods and data into the File Owner, my subclassed
NSWindowController. Is
that the correct way to do it? If not, what object type should it be a
subclass of?
I find if I throw everything at the window controller then it starts to
get very complicated and unorganized. Now I try to keep most of my UI
handling in several smaller controller classes and the window
controller ties these classes all together. One example is a
TableViewController which acts as both the data source and the
delegate. If the table doesn't support sorting or searching, then I
usually just request an array from another controller inside the data
source methods - I see no problem if the array isn't an instance
variable of the data source.
If the table does support sorting and/or searching, then I add an array
instance variable to the TableViewController which only contains the
objects the table view sees. If I need to do a search to limit what is
displayed in the table view or change the order the objects are
arranged, I simply change that instance variable and don't alter the
model's data. This works very well for me.
It is a little bit tricky keeping the two arrays in sync when some of
the data changes, but for me it is well worth it for a cleaner design.
Ryan
_______________________________________________
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.