Re: What's the argument aTableView used for?
Re: What's the argument aTableView used for?
- Subject: Re: What's the argument aTableView used for?
- From: Andy Lee <email@hidden>
- Date: Tue, 18 Sep 2007 09:28:05 -0400
It depends on how much code is in your data source methods and how
much is common to the different table view instances. A switch
statement or an if-then is simpler and more readable in many cases
than creating a separate class.
Even if you only have one table view, your data source method may
want to send a message to it or pass it as an argument to some other
method.
Another way to think of it is that data sources are a way to add
behavior to a table view without subclassing NSTableView. Think of
each data source method as being like a method on the table view.
Instead of self (the table view) being an implicit argument to the
method, it has to be explicit.
Note that besides all the data source methods in Cocoa, all the
delegate methods take the delegator as their first argument, for the
same reasons.
On a more general note, switch statements can be a red flag in object-
oriented code, but it really depends.
--Andy
On Sep 18, 2007, at 4:54 AM, Frank Bettger wrote:
Thanks, Chris,
I suspected that, but wouldn't it be cleaner if you had multiple
dataSource
objects, one for each NSTableView instance. (Even if there are
interdependencies between the tables there is nothing preventing
you from
reading other table models from within your code.) Is there any
advantage to
use the same object for multiple NSTableView instances?
On 9/18/07, Chris Suter <email@hidden> wrote:
In case you use the same object for multiple NSTableView instances.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden